Wednesday 9 May 2012

Tune Player

Click the icons below:





Purpose:

The purpose of this project was to try our hand at producing audio through Arduino. After spending the majority of the year on temperature we decided that looking into sound would be a great way to finish the year on a high. As we got deeper into the project it became less about trying to produce sound as to trying to improve the somewhat weak code that we were provided. The project then became a problem solving assignment as well as a test of our creativity based on what we wanted/were determined to add. 


Procedure:

We first looked at the circuit design that was in 30 Projects for the evil Genius and after getting a general understanding we built it. Then we looked at the Tune Player code from 30 Projects for the Evil Genius to get a sense of how the sounds were created and the method in which the author used to play songs. After we had a better understanding of the code that was provided we uploaded the sketch and ran it. We noticed right away that the tune player was not what we expected to hear. We thought about ways to improve it such as adding sharps, multiple octaves, and different note durations. After completing all the improvements we ran the new sketch and the difference was amazing. 



*IMPORTANT*
The array sin16[.......] in my Arduino sketch is VERY important. It simulates a sin wave. Because we are using a 4 bit amplifier we can only get a maximum of 16 points on our sin wave. 7 being the middle, 15 being the maximum and 0 being the lowest (0-->15 = 16....dont be off by one). The matrix toneDurations[3]12]{...} determines the rate at which we run through the sin wave, hence the name toneDurations. It does not produce the sin wave but instead determine the frequency of the wave, therefore producing the pitch.

Parts List:
1 100nF non-polarized capacitor
1 100uF, 16v electrolytic capacitor
5 10k ohm resistors
3 4.7k ohm resistors
1 1M ohm resistor
1 100k ohm resistor
1 TDA7052 1W audio amplifier
Miniature 8 ohm loudspeaker

Check out R2R Digital to Analog converter overview