powered by TinkerSpace.in
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
import bluetooth

setup:
    bluetooth_begin()  # switches Bluetooth on when the board starts

loop:
    bt = bluetooth_read_char()
    if bt == 'S':
        o1 = pwm(100)
    elif bt == 's':
        o1 = 0