Hi everyone,
As I mentioned in a couple of other topics - I am working on a "Simon says" handheld game.
For those who are not familiar - its a kind of game where the computer blinks different lights in a particular sequence and the player then needs to repeat it by pressing the buttons in the correct order.
Anyway, I though it would be really cool to add some sound to the game, for example game could make different sounds for different colours, so it would be easier to memorize the sequence and repeat it.
Or also play game over / victory music.
My project does have a limitation though - I want to transfer this game to an attiny45 chip which has much less memory and RAM available compared to the 328p chips. So unfortunately I can not use the tone() library, a simple project that plays 3 notes with it weights at least 2.5K and that is what my whole game currently weighs.
I decided to write my own implementation to keep the size of the whole project small.
Unfortunately I don't know much about how piezo speakers work, I hope someone could put me on the right track.
My main concerns at this point:
-
I don't think its a good idea to use PWM for this because from what I understand - changing frequency quickly and to specific rates can be quite a complex task and may require a lot of code - please correct me if I am wrong on this one.
-
Because of that I think it is best to just manually set the pin on/off inside the loop, changing the time between switches to change the frequency. Do you think this is a good idea?
Thanks in advance!