I’ve prototyped and tested the attached circuit and it’s code. Really straight forward: play notes and power LEDs in a sequence to emulate a song when the circuit closes, then wait for the accelerometer to output a large enough variance indicating that it’s being shaken which then starts the song again.
The problem is that if you switch the circuit on-off-on within a second or so in-between the off-on sequence, a few notes are incorrect and play as if something in memory is now corrupted. Turning it off and waiting more than 5 seconds and the toy returns to nominal operation. I understand that there is still enough charge in the capacitors to not allow memory to fully be released, but what is the proper way to avoid this kind of issue?
I’ve played with the idea of using transistors to solve this problem, but just can figure it out. How would one design a circuit that prevents the main circuit from closing again until the IC is fully discharged?