The whole project started after seeing a commercial for the toy on a Jaboody Dub's twitch stream. The meme potential was just off the charts.
Hardware wise, it's an ESP32 running Arduino which plays audio from a SD card via an i2s dac+amp. Also there's with a few transistors to drive the R/G led in the Zandar's orb. For inputs, there's a pushbutton in the back and a LDR to detect the a hand wave hidden in his hat. It's powered from the original x4 AA's (regulated via the dev board's LDO).
The code is based on Xtronical's awesome writeup on working with i2s (https://www.xtronical.com/i2s_ep4/ in particular).
The TL;DR on the code flow is: initialize hardware, scan the SD card for files, wait for input, play sfx sound, play answer sound, goto: wait for input. Also, on the second core, I'm controlling the LEDS by adjusting the color and brightness based on the current audio bank and current data being sent to the dac respectively.
Currently, I have 4 folders in the SD card (yes/no/meme/sfx) where each folder is a audio bank of answers. There's some logic implemented in the code to prevent repeats as well.
Beyond just the initial struggle of finding and getting a audio library to play nice, the biggest headache was just getting a solid response from the LDR for the wave detection. Triggering from a straight threshold was a little janky, so I ended up passing the ADC through two low pass filters, one running 'fast' and the other 'slow'. Then I'd take the (fast - slow) value against a threshold value and that seemed to play nicer.
The biggest thing I'm still battling with is if you're just waving Zandar around, sometimes it'll detect a trigger if it's pointed directly at a light source. Ideally I would have liked to used an IR emitter/detector pair instead, but since it's in a plastic globe so I didn't think that'd go too well...
- Voice Recognition (either full or just enough to use as a trigger)
- Smoke (hook up a vape to get some spooky effects)
- Hidden Cap-Touch (used to 'force' answer banks)
- Port to IDF v4.2 (In progress...)