You are on page 1of 2

########## DIGITAL MANUFACTURING

##########
# PIKACHU Project
# Authors: Miguel Angel Guzman
# Kadriye Nur Bakirci
###################################
########

########## IMPORT REQUIRED LIBRARIES


##########

import bluetooth
from ble_uart_peripheral import BLEUART
from machine import Pin
lampe=Pin(23, Pin.OUT)

# Create BLE object


ble = bluetooth.BLE()
# Open UART session for BLE
uart = BLEUART(ble)
# Define ISR for an UART input on BLE
connection
def on_rx():
# Read UART string, AppInventor sends raw
bytes
uart_in = uart.read() # lire le message recu du
Smartphone via Bluetooth
print("UART IN: ", uart_in.decode()) # afficher le
message recu du Smartphone sur le console de
Thonny
if (uart_in.decode().find('1')==0):
lampe.value(1) # allumer la lampe
else :
lampe.value(0) # éteindre la lampe
# Map ISR to UART read interrupt
uart.irq(handler=on_rx)
uart.close()

You might also like