DIY HACK – HOWTO make some sounds with Arduino! Sound Part 3 – Playing a Melody

DIY HACK - HOWTO make some sounds with Arduino! Sound Part 3 - Playing a Melody

Check out the Part 3 of “HOWTO make sounds with Ardunio” and learn to play melody.

Bit-Banging Sound
To bit-bang sound we toggle an output pin at the desired frequency. To play a musical note, we need to use specific frequencies and play the sound for a specific amount of time.

Generating the desired frequency big-bang style means figuring out what the period or cycle time of the desired frequency is. This is easy to calculate, it’s the reciprocal (1/F) of the frequency. As we found in part 2, 1KHz is 1000 cycles per second. So, one cycle takes 1 one-thousandth (1/1000) of a second or 0.001 seconds (1 millisecond). We need to toggle the pin at this rate so we want to keep it low for 1/2 the time then high for 1/2 the time. Therefore we want to set the I/O pin low for 500uS, then high for 500uS and do this over and over for as long as the duration requires.

Part I and Part II

via uchobby

Related Posts:

DIY HACK - HOWTO make a Arduino Beer Thermostat3

HOWTO make Beer Thermostat with Arduino

http://zedomax.com/image/200611/audiovideocontroller.jpg

Here’s a cool audio and video controller DIY using Arduino.


Leave a Reply

Your email address will not be published.


Check out more interesting categories: Arduino, Audio, Circuits, DIY, Hack, Microcontroller, Misc, Music.


Related News and Resources