Monday, 8 February 2016

GSM Based Notice Board


Project Theory

This project is a simple GSM Based project where 20x4 LCD is used as display for Notice board and GSM modem is used for receiving and sending SMS. When a user wants to display a notice/message on the notice board, user will send sms from a verified mobile number and sms recevied is displayed on LCD. Project involves simple security feature where SMS sender's number is compared with a pre-configured number (hardcoded in source code). If sms is recevied from an unknown sender, a notification SMS is sent to pre-configured number notifying an invalid access to board.

This project is fairly simple but its main purpose is to demonstrates reading and sending SMS using GSM Modem. There are many users on forum who struggles getting SMS read working in their projects. So For them this project is a starting point.




  







Poject Software / Source Code


/* Project Name : GSM Based Notice Boad
   Developer    : Subrata Malakar
 */
#include<reg51.h>
#include<string.h>
#include<absacc.h>
#include<stdlib.h>
#include<ctype.h>
#define buffer 110
                  
sbit rs = P3^5;
sbit e = P3^4;

void display_msg();
void delay(unsigned int i);
void lcdstr(unsigned char *s);
void lcdcmd(unsigned char val);
void lcddata(unsigned char val);
void lcdinit();
void tx0(unsigned char);
void SMSString(unsigned char*text) ;
void init();
void clear(void);
void read_notification();
void clear_mybuff();
void delete_msg(void);
void read_no(unsigned char msg_array[]);
void store_msg(unsigned char msg_array[]);
void password();
void read_nd_check_password(unsigned char msg_array[]);
unsigned char abc,apt=0,count=0;
unsigned char idata msg1[buffer];
unsigned char rec_no[10];
unsigned char time_date[10];
unsigned char code Response[] = "+CMTI";
// Moblie no.of Owner
unsigned char code Mob_no[]= "9739317976";
unsigned char code Pass_array[]="1234";
unsigned char MyBuff[20], k = 0;
bit flag1=0;
unsigned char store[10];
bit NewMessage = 0;
bit TI_flag = 0;
bit flag=0;
bit No_correct=0;

void lcdstr(unsigned char *s)
{
 unsigned int l,i;
 l = strlen(s);               // get the length of string
 for(i=1;i<=l;i++)
 {
  lcddata(*s);              // write every char one by one
  s++; 
 }
}
void lcdcmd(unsigned char val)
{     
    
        P1=val;
        rs=0;
        e=1;
        delay(1);
        e=0;
        return;
}

void delay(unsigned int i)
{
        unsigned int k, l;
        for(k=0;k<i;k++)
                for(l=0;l<1000;l++);
}
void lcddata(unsigned char val)
{
            
                P1=val; 
                rs=1;
                e=1;
                delay(1);
                e=0;
              return;
}
        

void lcdinit()
{
    lcdcmd(0x38); // 2 lines 5x7 matrix.
    delay(5);
    lcdcmd(0x0c); // Display ON Cursor Blinking.
    delay(5);
    lcdcmd(0x01); // Clear Display Screen.
    delay(5);
    lcdcmd(0x06); // Increment Cursor.
    delay(5);
  
}

void main ()
{

//if u do not want to check "OK" response after each AT command then
//enable interrupt IE=0X90 ; after last AT command of 
//SMSString( "AT+CMGR=1\r"); // AT command to read sms
//so after that u recieve a no of bytes from modile if u disable it then u do not reieve
//it even data comes
//    unsigned char t;
 
    clear();
    lcdinit();
    lcdcmd(0x80);
    lcdstr("Welcome to GSM");
    lcdcmd(0xc0);
    lcdstr("based Noticeboard");

    delay(10);
    init();
IT0 = 1;   // Configure interrupt 0 for falling edge on /INT0 (P3.2)
SMSString("AT\r"); // AT commands to initialize gsm modem
delay(50);

SMSString( "ATe0\r"); // turn off echo
delay(50);

SMSString( "AT&W\r"); // save settings
delay(50);

SMSString( "AT+CMGF=1\r"); // select text mode for sms
delay(50);
 
SMSString( "AT+CNMI=2,1,0,0,0\r"); // notification of new sms
while(1)
{

IE=0x91;
k=0;
delay(10);
flag=0;
while(!NewMessage);
{
    IE=0X00;
    delay(10);
    NewMessage = 0;
    read_notification();
}
//New msg indication.
// +CMTI: "SM",3
}

}
void read_notification()

    lcdcmd(0x01); //Clear LCD display.
    clear();
    SMSString("AT+CMGR=");
    tx0(MyBuff[12]);
    SMSString("\r");       
    IE=0x90;
    delay(200);
    read_no(msg1);
    IE=0x00;
    if(No_correct==1)
    {
   
        lcdcmd(0x80);
        lcdstr("Message Received");
        if(!isalpha(msg1[59]))    // checks for received msg is password or a actual msg(data).
        {
            read_nd_check_password(msg1);
      
        }
        else
            {
                store_msg(msg1);
                password();
                flag1=1;
            }
    }
    else
    {
        lcdcmd(0x01);
        lcdcmd(0x80);
        lcdstr("Msg frm Unknown");
        delay(1);
    }
    clear();

if(MyBuff[12]>='9')    //After 9 msgs recieved it clears the Msg index from SIM
{
    delete_msg();
}

clear_mybuff();

return;
}

void read_nd_check_password(unsigned char msg_array[])
{
if(Pass_array[0]==msg_array[59]&&
    Pass_array[1]== msg_array[60]&&
    Pass_array[2]==msg_array[61]&&
    Pass_array[3]== msg_array[62])
    {
        display_msg();
    }
    else
    {  
    SMSString("AT+CMGS=\"");
    SMSString(Mob_no);
    SMSString("\"\r");
    delay(1);
    SMSString("Password Incorrect!!");
    tx0(0x1A); // Ctrl+z
    delay(10);  
    }
return;
}
void password()
{
    SMSString("AT+CMGS=\"");
    SMSString(Mob_no);
    SMSString("\"\r");
    delay(1);
    SMSString("Send Your 4 Digit Password");
    tx0(0x1A); // Ctrl+z
    delay(10);  
return;
    }

void store_msg(unsigned char msg_array[])
{
unsigned char i,j;
i=59;
j=0;
    while(msg_array[i]!='\r')
    {
         store[j]= msg_array[i];
        i++;
        j++;
    }
return;
}

void display_msg()
{
    lcdcmd(0x01);
    lcdcmd(0x80);
    lcdstr("Received Msg");
    delay(1);
    lcdcmd(0xc0);
    lcdstr(store);
return;
}
void delete_msg(void)
{
    SMSString("AT+CMGD=9\r");
    delay(1);
    SMSString("AT+CMGD=8\r");
    delay(1);
    SMSString("AT+CMGD=7\r");
    delay(1);
    SMSString("AT+CMGD=6\r");
    delay(1);
    SMSString("AT+CMGD=5\r");
    delay(1);
    SMSString("AT+CMGD=4\r");
    delay(1);
    SMSString("AT+CMGD=3\r");
    delay(1);
    SMSString("AT+CMGD=2\r");
    delay(1);
    SMSString("AT+CMGD=1\r");
    delay(1);
    return;
}

void init()
{
P0=0x00;
    abc=0;
    TL1=0XFD; //9600 @ 11.0592
    TH1=0xFD;
    TMOD=0x20;
    SCON=0x50;
    TR1=1;
}
void SMSString(unsigned char* text) //function to send SMS using GSM modem
{
    while (*text)
    {
        tx0(*text++);
    }
}
void tx0(unsigned char x) //send data to serial port 0
{
    EA=0;
    SBUF=x;
    while(TI==0);
    TI=0;
    EA=1;
}
void serial () interrupt 4 {
unsigned char ch;
    if(RI){
      ch = SBUF; //character is read
      RI = 0; //clear flag
      if((ch == Response[k]) || (k > 4))
      {
           if(ch != 0x0D) // 0x0D means data received..
           {
                 MyBuff[k++] = ch;
           }
           else
           {
                   MyBuff[k] = '\0';
                NewMessage = 1;
                k = 0;
            }
       }     
           else
           {
            msg1[abc]=ch;//received msg is stored.
            abc++;
               k = 0;
           }
       }
}

void clear_mybuff()
{
    unsigned int a;
    for(a=0;a<25;a++)
        MyBuff[a]=0x00;
}
void clear(void)
{
    unsigned int a;
    for(a=0;a<buffer;a++)
        msg1[a]=0x00;
        abc=0;
}

void read_no(unsigned char msg_array[])      // reads the no from received msg and compares it with stored msg, If found wrong then send a msg to owner.
{
unsigned char i;
    if(Mob_no[0]==msg_array[23]&&
    Mob_no[1]== msg_array[24]&&
    Mob_no[2]==msg_array[25]&&
    Mob_no[3]== msg_array[26]&&
    Mob_no[4]==msg_array[27]&&
    Mob_no[5]== msg_array[28]&&
    Mob_no[6]==msg_array[29]&&
    Mob_no[7]== msg_array[30]&&
    Mob_no[8]==msg_array[31]&&
    Mob_no[9]== msg_array[32])
    {
        No_correct=1;
    }
    else    // Sends a msg to stored no if some unauthoriesd tries to send a msg.
    {
             No_correct=0;
            SMSString("AT+CMGS=\"");
            SMSString(Mob_no);
            SMSString("\"\r");
            delay(1);
            SMSString("Msg from Unknown number:( ");
            for(i=23;i<=32;i++)
            {
            tx0(msg_array[i]);
            delay(0);
            }
            SMSString(") is received.");
                tx0(0x1A); // Ctrl+z
            delay(100);  
    }
return;
}

Musical Tone Libray for 8051 Microcontoller


Background Theory

There are seven pitch classes which are represented by first seven letters of Latin alphabets (A, B, C, D, E, F and G). A musical note is represented by Pitch class and octave level, So according to pitch classes there are basic 7 notes and 8th note is represented with as same pitch class as first but double the frequency. The octave is used to differentiate between two notes and is a representation of frequency ratio of two.

Musical notes start from C0, c0#, D0, D0#,.... the lowest note frequency i.e. for C0 is 16.35Hz (based on center frequency A4, 440Hz). Another major component of musical note is duration. There are total 10 durations which are Quarter, Whole, Half, Eighth, Sixteenth, Thirty Two, Sixtyfour, six, twelve and twenty four. These durations vary depending on tempo (beats per minute) of the music/tone.

In music library we focused on notes from C5 to B6 as they coveres almost all variations for simple tone generation and octave level is produce good sound level on hardware (lower frequency means lower sound, higher the frequency higher the sound).

Implementation

Generating a particular frequency is nothing but a square wave with desired time period. We can use one of the 8051's timer to generate a particular frequency. Lets say if you want to generate C5 note which has a frequency of 523.25Hz, the time period for C5 will be 1911.132µS. The output square wave with 50% duty cycle will have high and low time of 955.566µS (= 1911.132/2).

Lets say your controller running at 12Mhz oscillator will have one Machine cycle of 1µs. To generate 955.566µs we need 956 (~=955.566/1) machine cycles. We can load timer with a value of 64580 (65536-956) and toggle any I/O pin at that interval will give us the reqired frequency. Now this I/o pin can be connected to a speaker to produce sound for that note.

In the library provided we are using Timer2 in auto reload mode for square wave generation. You can use any timer i.e. timer0 or timer1 in 16bit mode for frequency generation. For your convenience I have provided an excel sheet that will generate timer values for a given crystal oscillator frequency.



The sample program and hex file produces following tones:
1. Adam's Family
2. Looney Toons
3. Flintstones
4. Pink Panther
5. Beethoven Play
6. SaReGaMa (Basic Indian sound 7 tones in forward and reverse order).

Project Source Code / Software

#include <reg52.h>
#include <intrins.h>

sbit P3_7 = P3 ^ 7;

#define pitch_P        0
#define pitch_C5    64580
#define pitch_Db5    64634
#define pitch_D5    64685
#define pitch_Eb5    64732
#define pitch_E5    64778
#define pitch_F5    64820
#define pitch_Gb5    64860
#define pitch_G5    64898
#define pitch_Ab5    64934
#define pitch_A5    64968
#define pitch_Bb5    65000
#define pitch_B5    65030
#define pitch_C6    65058
#define pitch_Db6    65085
#define pitch_D6    65110
#define pitch_Eb6    65134
#define pitch_E6    65157
#define pitch_F6    65178
#define pitch_Gb6    65198
#define pitch_G6    65217
#define pitch_Ab6    65235
#define pitch_A6    65252
#define pitch_Bb6    65268
#define pitch_B6    65283

#define MelodyPin    P3_7

unsigned int qtrN, qtrN_us, wholeN, wholeN_us, halfN, halfN_us, eighthN, eighthN_us,
             sixteenN, sixteenN_us, thirtyTwoN, thirtyTwoN_us, sixtyFourN, sixtyFourN_us,
             sixN, sixN_us, twelveN, twelveN_us, twentyFourN, twentyFourN_us;

void Delay10MC(unsigned char);

void T2ISR(void) interrupt 5 {
    MelodyPin = ~MelodyPin;
    TF2 = 0;
}

void MelodyTempo(int Tempo){
    qtrN = ((60000/Tempo));
    wholeN = qtrN*4;
    halfN = (qtrN*2);
    eighthN = (qtrN/2);
    sixteenN = (qtrN/4);
    thirtyTwoN = (qtrN/8);
    sixtyFourN = (qtrN/16);
    sixN = (wholeN/6);
    twelveN = (wholeN/12);
    twentyFourN = (wholeN/24);
}

void PlayNote(const unsigned char PitchH, const unsigned char PitchL){
    RCAP2H = PitchH;
    RCAP2L = PitchL;
    TH2 = PitchH;
    TL2 = PitchL;
    TF2 = 0;
    TR2 = 1;
    ET2 = 1;
    EA = 1;
}

void EndNote(void){
    EA = 0;
    TR2 = 0;
    TF2 = 0;
    MelodyPin = 1;
}

void delay_ms(unsigned int ms){
    for(;ms>0;ms--)
        Delay10MC(100);
}

void Melodyplay(const int Pitch, unsigned int interval){
    if(Pitch!=0)
        PlayNote(Pitch >> 8, Pitch);
    delay_ms(interval);
    EndNote();
}

void LooneyToons(){ //d=4,o=5,b=140
    MelodyTempo(140);
    Melodyplay(pitch_C6, qtrN); //c6
    Melodyplay(pitch_F6, eighthN); //8f6
    Melodyplay(pitch_E6, eighthN); //8e6
    Melodyplay(pitch_D6, eighthN); //8d6
    Melodyplay(pitch_C6, eighthN); //8c6
    Melodyplay(pitch_A5, qtrN); //a.
    Melodyplay(pitch_A5, eighthN); //a.
    Melodyplay(pitch_C6, eighthN); //8c6
    Melodyplay(pitch_F6, eighthN); //8f6
    Melodyplay(pitch_E6, eighthN); //8e6
    Melodyplay(pitch_D6, eighthN); //8d6
    Melodyplay(pitch_Eb6, eighthN); //8d#6
    Melodyplay(pitch_E6, qtrN); //e.6
    Melodyplay(pitch_E6, eighthN); //e.6
    Melodyplay(pitch_E6, eighthN); //8e6
    Melodyplay(pitch_E6, eighthN); //8e6
    Melodyplay(pitch_C6, eighthN); //8c6
    Melodyplay(pitch_D6, eighthN); //8d6
    Melodyplay(pitch_C6, eighthN); //8c6
    Melodyplay(pitch_E6, eighthN); //8e6
    Melodyplay(pitch_C6, eighthN); //8c6
    Melodyplay(pitch_D6, eighthN); //8d6
    Melodyplay(pitch_C6, eighthN); //8c6
    Melodyplay(pitch_A5, eighthN); //8a
    Melodyplay(pitch_C6, eighthN); //8c6
    Melodyplay(pitch_G5, eighthN); //8g
    Melodyplay(pitch_Bb5, eighthN); //8a#
    Melodyplay(pitch_A5, eighthN); //8a
    Melodyplay(pitch_F5, eighthN); //8f
    Melodyplay(pitch_P, wholeN); //1P
}

void Flintstones(){//d=4,o=5,b=200
    MelodyTempo(200);
    Melodyplay(pitch_Ab5, qtrN); //g#
    Melodyplay(pitch_Db5, qtrN); //c#
    Melodyplay(pitch_P, eighthN); //8p
    Melodyplay(pitch_Db6, qtrN); //c#6
    Melodyplay(pitch_Bb5, eighthN); //8a#
    Melodyplay(pitch_Ab5, qtrN); //g#
    Melodyplay(pitch_Db5, qtrN); //c#
    Melodyplay(pitch_P, eighthN); //8p
    Melodyplay(pitch_Ab5, qtrN); //g#
    Melodyplay(pitch_Gb5, eighthN); //8f#
    Melodyplay(pitch_F5, eighthN); //8f
    Melodyplay(pitch_F5, eighthN); //8f
    Melodyplay(pitch_Gb5, eighthN); //8f#
    Melodyplay(pitch_Ab5, eighthN); //8g#
    Melodyplay(pitch_Db5, qtrN); //c#
    Melodyplay(pitch_Eb5, qtrN); //d#
    Melodyplay(pitch_F5, halfN); //2f
    Melodyplay(pitch_P, halfN); //2p
    Melodyplay(pitch_Ab5, qtrN); //g#
    Melodyplay(pitch_Db5, qtrN); //c#
    Melodyplay(pitch_P, eighthN); //8p
    Melodyplay(pitch_Db6, qtrN); //c#6
    Melodyplay(pitch_Bb5, eighthN); //8a#
    Melodyplay(pitch_Ab5, qtrN); //g#
    Melodyplay(pitch_Db5, qtrN); //c#
    Melodyplay(pitch_P, eighthN); //8p
    Melodyplay(pitch_Ab5, qtrN); //g#
    Melodyplay(pitch_Gb5, eighthN); //8f#
    Melodyplay(pitch_F5, eighthN); //8f
    Melodyplay(pitch_F5, eighthN); //8f
    Melodyplay(pitch_Gb5, eighthN); //8f#
    Melodyplay(pitch_Ab5, eighthN); //8g#
    Melodyplay(pitch_Db5, qtrN); //c#
    Melodyplay(pitch_Eb5, qtrN); //d#
    Melodyplay(pitch_Db5, halfN); //2c#
}

void AdamsFamily()
{ //d=4, o=6, b=50
    MelodyTempo(50);
    Melodyplay(pitch_P, thirtyTwoN); //32P
    Melodyplay(pitch_Db6, thirtyTwoN); //32c#
    Melodyplay(pitch_Gb6, sixteenN); //16f#
    Melodyplay(pitch_Bb6, thirtyTwoN); //32a#
    Melodyplay(pitch_Gb6, sixteenN); //16f#
    Melodyplay(pitch_Db6, thirtyTwoN); //32c#
    Melodyplay(pitch_C6, sixteenN); //16c
    Melodyplay(pitch_Ab6, eighthN); //8g#
    Melodyplay(pitch_Gb6, thirtyTwoN); //32f#
    Melodyplay(pitch_F6, sixteenN); //16f
    Melodyplay(pitch_Ab6, thirtyTwoN); //32g#
    Melodyplay(pitch_F6, sixteenN); //16f
    Melodyplay(pitch_Db6, thirtyTwoN); //32c#
    Melodyplay(pitch_Bb5, sixteenN); //16a#5
    Melodyplay(pitch_Gb6, eighthN); //8f#
    Melodyplay(pitch_Db6, thirtyTwoN); //32c#
    Melodyplay(pitch_Gb6, sixteenN); //16f#
    Melodyplay(pitch_Bb6, thirtyTwoN); //32a#
    Melodyplay(pitch_Gb6, sixteenN); //16f#
    Melodyplay(pitch_Db6, thirtyTwoN); //32c#
    Melodyplay(pitch_C6, sixteenN); //16c
    Melodyplay(pitch_Ab6, eighthN); //8g#
    Melodyplay(pitch_Gb6, thirtyTwoN); //32f#
    Melodyplay(pitch_F6, sixteenN); //16f
    Melodyplay(pitch_Db6, thirtyTwoN); //32c#
    Melodyplay(pitch_Eb6, sixteenN); //16d#
    Melodyplay(pitch_F6, thirtyTwoN); //32f
    Melodyplay(pitch_Gb6, qtrN); //f#
    Melodyplay(pitch_Db6, thirtyTwoN); //32c#
    Melodyplay(pitch_Eb6, thirtyTwoN); //32d#
    Melodyplay(pitch_F6, thirtyTwoN); //32f
    Melodyplay(pitch_Gb6, qtrN); //f#
    Melodyplay(pitch_Db6, thirtyTwoN); //32c#
    Melodyplay(pitch_Eb6, thirtyTwoN); //32d#
    Melodyplay(pitch_G6, thirtyTwoN); //32g
    Melodyplay(pitch_Ab6, qtrN); //g#
    Melodyplay(pitch_Eb6, thirtyTwoN); //32d#
    Melodyplay(pitch_F6, thirtyTwoN); //32f
    Melodyplay(pitch_G6, thirtyTwoN); //32g
    Melodyplay(pitch_Ab6, sixteenN); //16g#.
    Melodyplay(pitch_Ab6, eighthN); //16g#.
    Melodyplay(pitch_Eb6, thirtyTwoN); //32d#
    Melodyplay(pitch_F6, thirtyTwoN); //32f
    Melodyplay(pitch_G6, thirtyTwoN); //32g
    Melodyplay(pitch_Ab6, sixteenN); //16g#.
    Melodyplay(pitch_Ab6, eighthN); //16g#.
    Melodyplay(pitch_Db6, thirtyTwoN); //32c#
    Melodyplay(pitch_Eb6, thirtyTwoN); //32d#
    Melodyplay(pitch_F6, thirtyTwoN); //32f
    Melodyplay(pitch_Gb6, thirtyTwoN); //32f#
}

void PinkPanther(){//d=4,o=5,b=160
    MelodyTempo(160);
    Melodyplay(pitch_Eb5, eighthN); //8d#
    Melodyplay(pitch_E5, eighthN); //8e
    Melodyplay(pitch_P, halfN); //2p
    Melodyplay(pitch_Gb5, eighthN); //8f#
    Melodyplay(pitch_G5, eighthN); //8g
    Melodyplay(pitch_P, halfN); //2p
    Melodyplay(pitch_Eb5, eighthN); //8d#
    Melodyplay(pitch_E5, eighthN); //8e
    Melodyplay(pitch_P, sixteenN); //16p
    Melodyplay(pitch_Gb5, eighthN); //8f#
    Melodyplay(pitch_G5, eighthN); //8g
    Melodyplay(pitch_P, sixteenN); //16p
    Melodyplay(pitch_C6, eighthN); //8c6
    Melodyplay(pitch_B5, eighthN); //8b
    Melodyplay(pitch_P, sixteenN); //16p
    Melodyplay(pitch_Eb5, eighthN); //8d#
    Melodyplay(pitch_E5, eighthN); //8e
    Melodyplay(pitch_P, sixteenN); //16p
    Melodyplay(pitch_B5, eighthN); //8b
    Melodyplay(pitch_Bb5, halfN); //2a#
    Melodyplay(pitch_P, halfN); //2p
    Melodyplay(pitch_A5, sixteenN); //16a
    Melodyplay(pitch_G5, sixteenN); //16g
    Melodyplay(pitch_E5, sixteenN); //16e
    Melodyplay(pitch_D5, sixteenN); //16d
    Melodyplay(pitch_E5, halfN); //2e
}

void BeethovenPlay(){
    MelodyTempo(240);
    Melodyplay(pitch_E6, qtrN);
    Melodyplay(pitch_Eb6, qtrN);
    Melodyplay(pitch_E6, qtrN);
    Melodyplay(pitch_Eb6, qtrN);
    Melodyplay(pitch_E6, qtrN);
    Melodyplay(pitch_B5, qtrN);
    Melodyplay(pitch_D6, qtrN);
    Melodyplay(pitch_C6, qtrN);
    Melodyplay(pitch_A5, halfN);
    Melodyplay(pitch_C5, qtrN);
    Melodyplay(pitch_E6, qtrN);
    Melodyplay(pitch_A6, qtrN);
    Melodyplay(pitch_B6, halfN);
   
    Melodyplay(pitch_E5, qtrN);
    Melodyplay(pitch_A5, qtrN);
    Melodyplay(pitch_B5, qtrN);
    Melodyplay(pitch_C6, halfN);
}

void Saregama(){
    MelodyTempo(240);
    Melodyplay(pitch_Db5, qtrN);
    Melodyplay(pitch_Eb5, qtrN);
    Melodyplay(pitch_F5, qtrN);
    Melodyplay(pitch_Gb5, qtrN);
    Melodyplay(pitch_Ab5, qtrN);
    Melodyplay(pitch_Bb5, qtrN);
    Melodyplay(pitch_C6, qtrN);
    Melodyplay(pitch_Db6, qtrN);
    Melodyplay(pitch_P, wholeN);
    Melodyplay(pitch_Db6, qtrN);
    Melodyplay(pitch_C6, qtrN);
    Melodyplay(pitch_Bb5, qtrN);
    Melodyplay(pitch_Ab5, qtrN);
    Melodyplay(pitch_Gb5, qtrN);
    Melodyplay(pitch_F5, qtrN);
    Melodyplay(pitch_Eb5, qtrN);
    Melodyplay(pitch_Db5, qtrN);
}

void main(){
    while(1){
        AdamsFamily();
        delay_ms(1000);
        LooneyToons();
        delay_ms(1000);
        Flintstones();
        delay_ms(1000);
        PinkPanther();
        delay_ms(1000);
        BeethovenPlay();
        delay_ms(1000);
        Saregama();
        delay_ms(1000);
    }