Powered by TinkerSpace
Join free
TinkerPy App lessons
๐Ÿ’ก
Lesson 2 of 8 ยท Starter ยท 10 min

Your first app: a light switch

Add a Switch widget and turn an LED on from your phone.

  1. Open App โ†’ New App.
  2. Tap + Add Widget and choose Switch.
  3. Tap the Switch: in its code you see on โ†’ send "S" and off โ†’ send "s".
  4. Put the board code below on your TinkerPy board.
  5. Tap Run, then Connect โ†’ Bluetooth, and flip your switch!

This is the board side โ€” it listens for S and s:

Board code

Put this on your TinkerPy board with TinkerPy Projects:

Board
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)
Chat with TinkerPy ๐Ÿ‘‹