Create Musical Tone Using PIC Microcontroller[Step by Step ]
In this tutorial , i will show how to create melody using microcontroller and in this tutorial i will use pic18f2550 microcontroller .So let's create a project in proteus .
Proteus Project :
Please follow the instructions given below :
 Now pick pic18f2550, sounder, crystal,22pf capacitor,VDD and ground according to the instructions given below :
Now complete the circuit as given below :
MikroC Code :
Now we need the source code .So create a project in MikroC and follow the instructions given below:
Source Code :
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
(adsbygoogle = window.adsbygoogle || []).push({});
void Tone1() {  Sound_Play(659, 250);  // Frequency = 659Hz, duration = 250ms } void Tone2() {  Sound_Play(698, 250);  // Frequency = 698Hz, duration = 250ms } void Tone3() {  Sound_Play(784, 250);  // Frequency = 784Hz, duration = 250ms } void Melody() {          // Plays the melody "Yellow house"  Tone1(); Tone2(); Tone3(); Tone3();  Tone1(); Tone2(); Tone3(); Tone3();  Tone1(); Tone2(); Tone3();  Tone1(); Tone2(); Tone3(); Tone3();  Tone1(); Tone2(); Tone3();  Tone3(); Tone3(); Tone2(); Tone2(); Tone1(); } void ToneA() {  Sound_Play( 880, 50); } void ToneC() {  Sound_Play(1046, 50); } void ToneE() {  Sound_Play(1318, 50); } void main() {    ADCON1=0x0F;  //disable adc    CMCON=7;        //disable comparator  Sound_Init(&PORTC,0);  Sound_Play(880, 1000);            // Play sound at 880Hz for 1 second  while (1) {  ToneA();  delay_ms(100);  ToneC();   delay_ms(100);  ToneE();   delay_ms(100);  Melody();  } }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Now follow the next instructions .
.
Now just run the project.
Thank You!
http://feeds.feedburner.com/microcontroller_for_beginners















