51 single chip music player

Publisher:JikaiLatest update time:2016-08-23 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
        //Data table of "Only Mom is Good in the World"

co de unsigned char sszymmh[]={ 6,2,3, 5,2,1, 3,2,2, 5,2,2, 1,3,2, 6,2,1, 5,2,1 ,
                                      6,2,4, 3,2,2, 5,2,1, 6,2,1, 5,2,2, 3,2,2, 1,2,1,
                                      6,1,1, 5 ,2,1, 3,2,1, 2,2,4, 2,2,3, 3,2,1, 5,2,2,
                                      5,2,1, 6,2,1, 3,2 ,2, 2,2,2, 1,2,4, 5,2,3, 3,2,1,
                                      2,2,1, 1,2,1, 6,1,1, 1,2,1 , 5,1,6, 0,0,0 
                                      };
       // Frequency table high eight bits
code unsigned char FREQH[]={
                                0xF2,0xF3,0xF5,0xF5,0xF6,0xF7,0xF8, 
                                0xF9,0xF9,0xFA, 0xFA,0xFB,0xFB,0xFC,0xFC, //1,2,3,4,5,6,7,8,i
                                0xFC,0xFD,0xFD,0xFD,0xFD,0xFE, 0xFE
                                ,0xFE,0xFE,0xFE,0xFE ,0xFE,0xFF,
                               } ;
         // Low eight bits of the scale frequency table
code unsigned char FREQL[]={
                                 0x42,0xC1,0x17,0xB6,0xD0,0xD1,0xB6,
                                 0x21,0xE1,0x8C,0xD8,0x68,0xE9,0x5B,0x8F, //1,2,3,4,5,6,7,8,i
                                 0xEE ,0x44, 0x6B,0xB4,0xF4,0x2D, 
                                 ​​0x47,0x77,0xA2,0xB6,0xDA,0xFA,0x16,
                                };
void delay(unsigned char t)
   {
   unsigned char t1;
   unsigned long t2;
   for(t1=0;t1    {
    for(t2=0;t2<8000;t2++)
       {
        ;
        }
   }
   TR0=0;
}
void t0int() interrupt 1
{
TR0=0;
speaker=!speaker;
TH0=timer0h;
TL0=timer0l;
TR0=1;
}
void song()
{
TH0=timer0h;
TL0=timer0l;
TR0=1;
delay(time);                       
}

void main(void)
{
unsigned char k,i;
TMOD=1; //Set CT0 timing working mode 1
EA=1;
ET0=1;//IE=0x82 //CPU opens interrupt, CT0 opens interrupt 
while(1)
      {
       i=0; 
       while(i<100){ //Music array length, start over after singing        
       k=sszymmh[i]+7*sszymmh[i+1]-1;
       timer0h=FREQH[k];
       timer0l=FREQL[k];
       time=sszymmh[i+2];
       i=i+3;
       song();
        }
      } 
}

Reference address:51 single chip music player

Previous article:The use of 51 single chip microcomputer 24c02
Next article:51 single chip microcomputer lcd1602

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号