It is that time of year again...time for some spooky projects!
I have wanted to play with one of Adafruit's AudioFX sound boards for quite some time. Our customers love these boards, and they are perfect for Halloween props.
To keep things simple, I chose to use the 16 MB Audio FX Board with 2x2W amplifier. I like this board because you can wire up the speakers directly to it. In this case, I went with Adafruit's cheap and cheerful Stereo Enclosed Speaker Set. They have the added bonus of looking like eyes if you install them horizontally.
The Audio Effects board is simple to actuate. Send one of the trigger pins to ground and it triggers the effect. You can learn more about working with the board in the Adafruit Learning System.
My goal was to use a PIR sensor to detect motion and then play a sound. Easy right? The only problem is that the PIR sensor outputs 5V when it senses motion. That wouldn't work with the AudioFX board, so I used an NPN transistor with 100k and 1k resistors. I wired it per the diagram below, courtesy Adafruit. The Emitter is connected to ground, Base is connected to a 100k resistor that goes to the signal pin of the PIR motion sensor, and the Collector is connected to a 1k resistor that goes to 5V and the input pin.
I recorded some sound, uploaded it to the Audio FX board and got everything working, but the only problem was that the board would keep getting triggered by the PIR. I wanted the sounds to only come on once or twice while a potential trick or treater was on our porch. So, I added a Trinket M0 microcontroller!
I really like the Trinket M0 because it is small, relatively powerful, and best of all you can run CircuitPython on it. CircuitPython is a flavor of MicroPython, and I find it way less clunky than using the Arduino IDE. It also helps that I have some formal Python training and have never taken a C class in my life. :-)
With the addition of a microcontroller, now I could easily control the timing of how audio would play and also add some WS2812 LED's. We picked up some "Neopixel clones" from a Chinese supplier, and they work pretty well. They are not as easy to use as real Neopixels, so we do recommend beginners stick to the genuine Adafruit product.
With my circuit getting a bit more complicated, the risk of stuff falling out of a breadboard got higher. So I transferred everything to a Perma Proto board. This takes a bit more time, but it also makes the project way more robust.
Pro tip: mount your breakout boards on stacking headers. That way if you want to reuse them in another project, it is easy to do so!
All of this electronic goodness needed a place to live, so I built a laser-cut wooden case on our Glowforge. I did the initial box design using MakerCase, and then I added cutouts for the speakers, WS2812 rings, and some 3mm holes for screws. I added a spooky mouth for good measure. Feel free to download the SVG files for our case.
Like I said earlier, we coded this in CircuitPython. Everything about CP is straightforward. You just copy the libraries you need to the device, in this case, they were digitalio and neopixel. You then use either a text editor or an interface like mu. I like mu because you can easily view serial output, which can be handy for debugging. I borrowed a few of Adafruit's Neopixel libraries and put my Python expertise to work. While my code may not be pythonic, it works! Check out my code here.
After a bit of gluing, I think the final product turned out quite well!
Complete Bill of Material:
Comments will be approved before showing up.