Maker.io main logo

Firetruck Rescue Lights and Siren Using a Circuit Playground Express

2020-04-07 | By Kevin Walseth

License: See Original Project Circuit Playground

Many kids dream of becoming a firefighter, especially when their dad is a firefighter. My son is no different, so I built my son a firetruck bed for his 3rd birthday. It has taken me two years to find the time to create lights and a siren for it, but it was a fun project to do with him. Here is what I created and how I did it.

The Circuit Playground Express is a development board filled with sensors, LEDs, and IO’s for almost any project. I planned to use the capacitive touch input, onboard speaker, and output to a strip of Neopixel LEDs. Then, 3D print an enclosure to look like a firetruck “bubble” light bar. Let’s start with the hardware:

LED_1

Here is how to connect the LEDs:

How to connect the LEDs

Next, a wire will need to be connected to A3 for the Capacitive touch input

Connect wire to A3 for the Capacitive touch input

The Circuit Playground Express is ready to be programmed. To code with Circuit Python, check out this guide to set up your device.

circuit_4

Once you are ready to go, copy and paste this code in your CIRCUITPY drive as code.py

Copy Code
import random
import time
import board
import neopixel
import touchio
import digitalio
from audioio import WaveFile
from audioio import AudioOut

touch_pad = board.A3
touch = touchio.TouchIn(touch_pad)

spkrenable = digitalio.DigitalInOut(board.SPEAKER_ENABLE)
spkrenable.direction = digitalio.Direction.OUTPUT
spkrenable.value = True

audiofiles = ["siren2.wav", "siren.wav", ""]

def fireeffect():
pixel1.fill((55, 0, 0))
pixel1[random.randrange(45)] = (255, 0, 0)
pixel1[random.randrange(45)] = (200, 30, 0)
pixel1[random.randrange(45)] = (180, 50, 0)
pixel1[random.randrange(45)] = (220, 10, 0)

pixel1 = neopixel.NeoPixel(board.A1, 45, brightness=0.8)

def play_file(filename):
wave_file = open(filename, "rb")
with WaveFile(wave_file) as wave:
with AudioOut(board.SPEAKER) as audio:
audio.play(wave)
while audio.playing:
pass


audio = AudioOut(board.SPEAKER)
wave = WaveFile(open(audiofiles[1], "rb"))
time_started = 0

while True:
pixel1.fill((0, 0, 0))
now = time.monotonic()
if touch.value:
if not audio.playing:
audio.play(wave, loop=True)
time_started = now
if now - time_started < 7:
fireeffect()
elif audio.playing:
audio.stop()
pixel1.fill((0, 0, 0))

 

Here are the 3D printed files for the light bar:

 lightbar_5

And here is the assembled light bar:

assembled_6

The way I incorporated the capacitive touch input was to loop a wire out of, then back into, the 3d print model. This will work with an insulated wire and allows for it to read the input without touching bare wire. It will also give it a clean look.

clean_7

This is the final product. I do like using the on-board speaker, after-all it is in his bedroom, not a fire station, so it doesn’t need to be crazy loud.

complete_8

制造商零件编号 3333
CIRCUIT PLAYGROUND EXPRESS
Adafruit Industries LLC
制造商零件编号 727
BATTERY HOLDER AAA 3 CELL LEADS
Adafruit Industries LLC
制造商零件编号 2508
ADDRESS LED STRIP SERIAL RGB 1M
Adafruit Industries LLC
Add all DigiKey Parts to Cart
TechForum

Have questions or comments? Continue the conversation on TechForum, DigiKey's online community and technical resource.

Visit TechForum