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

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

loop:
    if i2 == ON:
        bluetooth_write("A")
        o1 = pwm(100)
    else:
        bluetooth_write("a")
        o1 = 0
    wait(500)