Hardware

A single custom PCB was used to drive all electronics in this project. The board has two STM32 M0+ microcontrollers, one for handling a servo motor and stereo audio and the other for controlling the LEDs, reading the color sensor, and detecting switch inputs. The board is powered from a 5V/2A AC/DC brick. The 5V is used directly for the LEDs and motor and regulated down to 3.3V to power the microcontrollers and logic interfaces.  The PCB was designed using KiCAD and manufactured by PCBWay. I did the assembly myself using a stencil (also from PCBWay), solder paste, and a hot air gun. 

I used the STM32L052C8T6 microcontroller for this project, because it is one of the lowest cost STM32 options with an I2S peripheral for driving the audio. The audio microcontroller reads .wav files from an SD Card and streams them out to two MAX98357A integrated audio DAC/Class-D amplifiers. The stepper motor controlling the character pointer is driven from the STM32's PWM peripheral.

The LEDs on the main board include a ring of 20 DotStars (APA102) and 4 stacked bar graphs. I prefer DotStars over NeoPixels as they are faster and seem to be a bit more reliable.

The discrete LEDs, speakers, and variety of panel mount switches all connect to the PCB by means of 0.1" pin headers. Using connectors rather than soldering made testing a lot simpler as I didn't have to leave the tangled mess of wires permanently connected to the board.  I made all of the mating connector cables using this nifty Dupont connector kit from Amazon.


Software

All code for this project was written in Visual Studio Code. I used STMicro's new STM32CubeIDE and a SEGGER J-Link EDU mini debugger to program the microcontrollers over SWD. Code for controlling the DotStars, bar graphs, and color sensor was ported to the STM32Cube framework from Adafruit's Arduino libraries (thanks Adafruit!).

Trying to get FatFs and audio playback working with the STM32 is a huge pain, but fortunately I already figured it out on a previous project. See my NFC Toy project page for some details.


Enclosure

The enclosure is made entirely from wood. The frame is build from a single 1x4" picked up at my local Home Depot. The center panel is made from a cedar plywood panel (also from Home Depot). I routed a channel all around the inside of the frame for the panel to slide into. The large panel cutout for the PCB was cut using a Jigsaw while the rest of the holes were made with a cordless drill and hole saw blades. The cover over the PCB was cut from a sheet of 1/16" acryllic (Home Depot again).


Demos