Powered by TinkerSpace
Join free
TinkerPy App lessons
๐Ÿ”ฅ
Lesson 4 of 8 ยท Explorer ยท 10 min

A fire alarm app

Use an output widget: the board tells the app when there is fire.

  1. Add the Fire widget (in Output โ†’ Safety & Alarms).
  2. Its code says: when the board sends A โ†’ show FIRE; a โ†’ SAFE.
  3. Optional: tap Sound โ†’ Speaker to play a siren on fire!
  4. Put the board code below on your board with a flame sensor on i2.

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():
    if read_digital(i2) == ON:
        bluetooth_write("A")
        write_output(o1, pwm(100))
    else:
        bluetooth_write("a")
        write_output(o1, 0)
    wait(500)
Chat with TinkerPy ๐Ÿ‘‹