Tuesday, February 12, 2013

Day 8 Music; Continue on "Toy Hacking" Project

02/23/2013

                       As we have already discussed, there are many output devices that can be controlled by the microprocessor. The microcontroller has pins for digital output that can control frequency for sound output from a speaker. The program's coding that required to control speaker is simply. The only variables needed are pin_numbers, frequency, and play_time.

here is a sample for the code:

void loop( )
{
     noTone(8);                             // turn off the tone function for pin #8
     tone(8, 440, 200);                  // play sound at 440hz for 200ms on pin#8
     delay(200);                            // silent for 200ms
}

Unfortunately, the videos related to music and sound output was lost, so there will not be any videos for examples.

              ------------------------------------------------------------------------------------------

Since there is no time to work on the project during class time, the project has to be done at home.

The circuit for the project is finally completed and the basic programming is finish.
 
A successful test run after hour of debugging the code.
 The music playing through the toy's speaker is controlled by the launchPad
 
The code for the music is exactly the same style as shown above on the top of the page. However, if you find entering every tone is annoying, you can use an array to store all the tones and let the microcontroller plays them according to their position in the array.

No comments:

Post a Comment