Snow globe intruder alert system

Snow globe intruder alert system

Learn how to build a snow globe that sounds an alarm and flashes a red alert when intruders are about. Me and my six year old daughter designed and built this project to have fun with friends and learn a bit about computers along the way.

Ce17126d6065d975c34973f3e55dc51b?s=128

Marwan Alsabbagh

June 09, 2018
Tweet

Transcript

  1. Snow globe intruder alert system Marwan AlSabbagh

  2. 1. Assemble 2. Code 3. Teach Structure

  3. 1. Assemble

  4. Circuit Playground Express • CircuitPython • $25 • No soldering

    • USB drive • Adafruit
  5. vs Comparison • I/O • Battery • Bootup

  6. Parts Circuit Playground Express $25 Snow Globe Kit $5 AAA

    Battery Holder $3 Conductive Thread $5 Total: $38 (28.50 GBP)
  7. Fill the globe Add Water Glycerin Glitter Dolly

  8. Glue the dolly

  9. Or else...

  10. First attempt

  11. Wooden base

  12. Batteries

  13. Wiring

  14. Conductive Thread length: 1.3 m

  15. Building is fun!!!

  16. 2. Code

  17. Coding • CircuitPython • usb drive • main.py • 2MB

    flash
  18. REPL • serial console • Linux/MacOS: screen /dev/ttyACM0 115200 •

    Mu Editor(Windows, MacOS, Linux)
  19. Circuit Playground API >>> from adafruit_circuitplayground.express import cpx >>> #

    speaker play tone at 800Hz for 500ms >>> cpx.play_tone(800, 0.5) >>> # set brightness for NeoPixels to 50 percent >>> cpx.pixels.brightness = 0.5 >>> # set first NeoPixel to the color red >>> cpx.pixels[0] = [255, 0, 0] >>> # set all 10 NeoPixels to the color green >>> cpx.pixels.fill([0, 255, 0]) >>> # check if slide switch is on or off >>> cpx.switch >>> True >>> # check if capacitive touch is detected on pad A2 >>> cpx.touch_A2 >>> False
  20. main function from adafruit_circuitplayground.express import cpx import time TONES =

    dict(low=800, high=960) RGB = dict(black=[0, 0, 0], blue=[0, 0, 255], green=[0, 255, 0], cyan=[0, 255, 255], red=[255, 0, 0], magenta=[255, 0, 255], yellow=[255, 255, 0], white=[255, 255, 255]) CYCLE = ['cyan', 'blue', 'magenta', 'red', 'green', 'yellow'] def beep(frequency=TONES['high']): cpx.play_tone(frequency, 0.4) def main(): cpx.pixels.brightness = 1.0 beep() while True: if cpx.switch: rainbow() else: detect() main()
  21. Rainbow mode

  22. rainbow function from adafruit_circuitplayground.express import cpx import time TONES =

    dict(low=800, high=960) RGB = dict(black=[0, 0, 0], blue=[0, 0, 255], green=[0, 255, 0], cyan=[0, 255, 255], red=[255, 0, 0], magenta=[255, 0, 255], yellow=[255, 255, 0], white=[255, 255, 255]) CYCLE = ['cyan', 'blue', 'magenta', 'red', 'green', 'yellow'] def rainbow(): for color in CYCLE: for i in range(10): cpx.pixels[i] = RGB[color] time.sleep(0.3)
  23. Intruder alert mode

  24. detect and alarm function from adafruit_circuitplayground.express import cpx import time

    TONES = dict(low=800, high=960) RGB = dict(black=[0, 0, 0], blue=[0, 0, 255], green=[0, 255, 0], cyan=[0, 255, 255], red=[255, 0, 0], magenta=[255, 0, 255], yellow=[255, 255, 0], white=[255, 255, 255]) def alarm(): for i in range(3): cpx.pixels.fill(RGB['red']) beep(TONES['high']) cpx.pixels.fill(RGB['black']) beep(TONES['low']) def detect(): colors = ['green'] * 10 + ['black'] * 10 for color in colors: if cpx.touch_A2: alarm() cpx.pixels.fill(RGB[color]) time.sleep(0.05)
  25. 3. Teach

  26. REPL with a 6 year old • Command/Response • Math

    • Command history • Reduce Typing • Independent • learn about sound and light
  27. teach API >>> from teach import cpx, beep, led >>>

    # make speaker beep >>> beep() >>> # make speaker beep at 800Hz >>> beep(800) >>> # reduce brightness to a more comfortable level >>> cpx.pixels.brightness = 0.02 >>> # set first LED to white >>> led() >>> # set second LED to red >>> led('red', 1) >>> # set 1st LED to blue with hex color code >>> led('0000ff') >>> # set 1st LED to Magenta(red on, green off, blue on) >>> led('101')
  28. Sound

  29. Microscope 200x Magnification Cost: 30 GBP

  30. Color wheel

  31. RGB >>> led('yellow') >>> led('ffff00') >>> led('110')

  32. The End https://marwano.com/