A very simple circuit to make Arduino sing using NE555 and a digital potentiometer.
Basically Arduino controls MCP41010 digital potentiometer with SPI. Then instead of using digital potentiometer as a potentiometer, use it as a variable resistor. Therefore leave one terminal(either A or B) and them connect the rest two to the NE555. I used NE555 circuit from this web. It's more intuitive so I bet this will help a lot.
I used a generic NE555P. Most NE555 will work between 4.5V to 15V. However, ideal operating voltage is about 9V to 12V. I did find Arduino wasn't able to deliver constant 5V and the frequency changed dramatically but only when powered by a USB power bank or else. Just one thing to be aware of.
I chose 1uF capacitor because it will give me a good range of frequency from about 70Hz. This will well cover piano range.
I've attached the Arduino code. It's simple SPI communication. MCPWrite is the method that sends data to the MCP41010. Note SPI pins are reserved on Arduino and it does not need to set manually. CS is a pin which tells MCP if it should take the data or not.
More importantly, frequency chart(attached) will tell you which step on the potentiometer must be set in order to get a particular frequency. Use this intuitive chart to make your Arduino sing at whatever frequency you want!
This project my code of "KISS". It stands for Keep It Simple and Stupid. There's virtually no advantage of using this. Here's why:
This NE555 synthesizer
- You can use an earbud (that is likely to be too loud to put it in your ears.)
- NOT very specific frequency steps.
- NOT wide frequency coverage.
- Uses too many pins
- Simple but extremely more complicated than the alternative.
- Will require constant 5V(else NE555 starts to act werid)
- Coding is too complicated compared to the alternative.
A Buzzer (The best alternative)
- Super easy to use
- Super simple methods already exsit
- Uses only one pin
- Pretty wide frequency range,
- Pretty specific frequency steps.
- It looks like you've just attached a buzzer instead of having a fancy circuit.
- Will wake your neighbors up.
Therefore, This whole idea is kind of stupid. The only way I see this useful is to help understand NE555 or to teach concepts of using digital potentiometer, I guess. The point is, I can't find a good real life use of this.
At least this was fun building it and I learned how to use digital potentiometer so I guess it's cool.