The notes are played by the small speaker connected to the microcontroller.
ULN2803 is use to drive the speaker.
The U.A.R.T. of the 8051is utilized to send information from the pc to the microcontroller.
The notes of the music are played using the frequencies of different notes of music. Each octave in the synthesizer operates on a different frequency range and the corresponding values of the timer can be calculated using the frequencies of each note that can be easily found on the internet.
As per my calculations the different values to be loaded on timer for different octaves and corresponding notes are as follows. The timer should loaded with a value so that the time to overflow should be half the period of frequency´s note and turn on and of the speaker at each overflow ocurrency.
speaker on off on
|--------------| |--------
____| |__________________|
| half-period |
|<>|
The different decimal values to be loaded into the timer for the note generation corresponding to the different octaves are given as follows.
| 63441,63559,63670,63775,63874,63967,64055,64138,64217, 64291,64360,64426**4th octave |
| 64489,64547,64603,64655,64705,64751,64795,64837,64876, 64913,64948,64981**5th octave |
| 65012,65042,65069,65096,65120,65144,65166,65187,65206, 65225,65242,65259**6th octave |
| 65274,65289,65303,65316,65328,65340,65351,65361,65371, 65380,65389,65397**7th octave |
| 65405,65412,65419,65426,65432,65438,65443,65449,65454, 65458,65463,65467**8th octave |
Here is the source code for the above project.