I made an electronic animal for my project. I decided to make a gentle creature that falls asleep and starts to snore. The LEDs slowly fade to simulate falling asleep, and then blink awake when the animal first wakes up. I also wanted to make the snoring sound very soft and sweet, so I included a whistling sound on the exhale. It’s enclosed in a dust mop, which is soft and purple. Hopefully all these things together create a feelings of mildness and tenderness.
There were a few design challenges. I used a sound library so that I could record the sound onto the Arduino’s flash memory, rather than using an external WAV shield (although I think those might be fun and I may pick one up very shortly).
I found out through some initial errors that the sound function I used takes up two of the Arduino’s three timers, and therefore breaks the PWM function in pin 3, which is where I originally attached the LEDs. As a result, after the first time the animal fell asleep, the LEDs would no longer fade; they simply switched off. When I re-read the documentation on the library, plus the link here, I realized the mistake I’d made and changed the LEDs pin to 5, which still had the ability to fade out.
I also had to use trial and error to figure out how to make the photocell responsive. This tutorial on the Adafruit site helped a lot.
My code (along with a few iterations) is on my Github account here.
The video is here.