Want to make something interesting for Christmas?
How about an electronic quizzical Christmas card? It plays questions from wave files off an SD card, so you can customise it with thoughtful and/or creepy questions.
If quizzes are quizzical, this card is more of a test.
Remove these ads by
Signing UpStep 1The Quiz Game
The card plays the santee questions, and they must answer by pushing the A, B or C buttons.
If they get the answer wrong they have to do a penalty (in this case listen to Boney M christmas carols while repeatedly pressing a key to make sure they don't just run away)
Each time you get a question wrong the penalty level increases (ie you have to listen to an even longer Boney M clip)
| « Previous Step | Download PDFView All Steps | Next Step » |













































It's pretty simple, just make a global array of 1024 bytes if you can, a length variable and a pointer to the oldest byte. then use a timer interrupt to load the oldest byte into the PWM register, (TCCR0 or whatever), increment the pointer and decrement the length.
In your main loop just keep trying to fill the buffer with as much data as you can.
If you run the timer in phase correct PWM mode it will cycle every 512 clocks. You want to use the overflow interrupt so the next sample gets loaded every 512 clocks. If you want to sample at 16Khz your timer clock must run at (16*512)=8Mhz, so if you use an 8Mhz crystal you set the divider to 1.
Remember to keep your interrupt very short!
Also check if it runs at 3.3V
Mind you, it's over an hour's worth of audio.