Your TinkerPy App sends data (one character) when you tap a widget โ for example a Switch sends S for ON and s for OFF. The board reads it with bluetooth_read_char().
from tinkerpy_mega import * from bluetooth import * def setup(): bluetooth_begin() # switches Bluetooth on when the board starts def loop(): bt = bluetooth_read_char() if bt == 'S': write_output(o1, pwm(100)) elif bt == 's': write_output(o1, 0)
Sending to the app
bluetooth_write("A") sends data to the app. An output widget โ like Fire โ changes when its data arrives.
from tinkerpy_mega import * from bluetooth import * def setup(): bluetooth_begin() # switches Bluetooth on when the board starts def loop(): if read_digital(i2) == ON: bluetooth_write("A") write_output(o1, pwm(100)) else: bluetooth_write("a") write_output(o1, 0) wait(500)
๐ก Tip
Open the App lessons to build the app for this code!