zoukankan      html  css  js  c++  java
  • 蓝桥杯单片机类音乐(移植普中的8月桂花,建议一小时写完代码后播放四小时)

    #include<STC15F2K60S2.h>

    unsigned char n=0;  //n???????   
    unsigned char code music_tab[] ={  
    0x18, 0x30, 0x1C , 0x10, //???: ????, ????, ????, ????,   
    0x20, 0x40, 0x1C , 0x10,  
    0x18, 0x10, 0x20 , 0x10,  
    0x1C, 0x10, 0x18 , 0x40,  
    0x1C, 0x20, 0x20 , 0x20,  
    0x1C, 0x20, 0x18 , 0x20,  
    0x20, 0x80, 0xFF , 0x20,  
    0x30, 0x1C, 0x10 , 0x18,  
    0x20, 0x15, 0x20 , 0x1C,  
    0x20, 0x20, 0x20 , 0x26,  
    0x40, 0x20, 0x20 , 0x2B,  
    0x20, 0x26, 0x20 , 0x20,  
    0x20, 0x30, 0x80 , 0xFF,  
    0x20, 0x20, 0x1C , 0x10,  
    0x18, 0x10, 0x20 , 0x20,  
    0x26, 0x20, 0x2B , 0x20,  
    0x30, 0x20, 0x2B , 0x40,  
    0x20, 0x20, 0x1C , 0x10,  
    0x18, 0x10, 0x20 , 0x20,  
    0x26, 0x20, 0x2B , 0x20,  
    0x30, 0x20, 0x2B , 0x40,  
    0x20, 0x30, 0x1C , 0x10,  
    0x18, 0x20, 0x15 , 0x20,  
    0x1C, 0x20, 0x20 , 0x20,  
    0x26, 0x40, 0x20 , 0x20,  
    0x2B, 0x20, 0x26 , 0x20,  
    0x20, 0x20, 0x30 , 0x80,  
    0x20, 0x30, 0x1C , 0x10,  
    0x20, 0x10, 0x1C , 0x10,  
    0x20, 0x20, 0x26 , 0x20,  
    0x2B, 0x20, 0x30 , 0x20,  
    0x2B, 0x40, 0x20 , 0x15,  
    0x1F, 0x05, 0x20 , 0x10,  
    0x1C, 0x10, 0x20 , 0x20,  
    0x26, 0x20, 0x2B , 0x20,  
    0x30, 0x20, 0x2B , 0x40,  
    0x20, 0x30, 0x1C , 0x10,  
    0x18, 0x20, 0x15 , 0x20,  
    0x1C, 0x20, 0x20 , 0x20,  
    0x26, 0x40, 0x20 , 0x20,  
    0x2B, 0x20, 0x26 , 0x20,  
    0x20, 0x20, 0x30 , 0x30,  
    0x20, 0x30, 0x1C , 0x10,  
    0x18, 0x40, 0x1C , 0x20,  
    0x20, 0x20, 0x26 , 0x40,  
    0x13, 0x60, 0x18 , 0x20,  
    0x15, 0x40, 0x13 , 0x40,  
    0x18, 0x80, 0x00  
    };  
    void int0()  interrupt 1   //????0 ????   
    {  TH0=0xd8;  
       TL0=0xef;  
       n--;  
    }  
      
    void delay (unsigned char m)   //??????   
    {  
     unsigned i=3*m;  
     while(--i);  
    }  
      
    void delayms(unsigned char a)  //???????   
    {  
      while(--a);                  //??while(--a) ????while(a--); ?????????????????!   
    }  
    void allinit()
    {
     P2=0x80;
     P0=0xff;
     P2=0xa0;
     P0=0x00;
     P2=0x00;
    }
    void fengmingqikai()
    {
     P2=0xa0;
     P0=0x40;
     P2=0x00;
    }
    void main()  
    {
     unsigned char p,m;   //m???????   
      unsigned char i=0;  
     bit qq;
      TMOD&=0x0f;  
      TMOD|=0x01;  
      TH0=0xd8;TL0=0xef;  
      IE=0x82;  
    play:  
       while(1)  
        {  
        a: p=music_tab[i];  
           if(p==0x00)       { i=0, delayms(1000); goto play;}     //???????,??1?,????????   
           else if(p==0xff)  { i=i+1;delayms(100),TR0=0; goto a;}  //??????,??100ms,???????   
                else         {m=music_tab[i++], n=music_tab[i++];}  //????? ? ????   
                 TR0=1;                                             //????1   
               while(n!=0) {
           qq=~qq;
           {
           if(qq==0)
           {
            fengmingqikai();
           }
           else
           {
            allinit();
           }
           }
          
          delay(m);
          }                       //??????, ??P1?????(?????!)   
           TR0=0;                                             //????1   
        }  
  • 相关阅读:
    软件的开发流程(摘录百度百科)
    linux大全
    percona server 二进制安装下编译tpcc-mysql的坑
    Problems with MMM for mysql(译文)
    MySQL MMM 双主在Failover时挂起
    Steve Loughran:Why not raid 0,its about time and snowflakes!!!
    React-Redux 源码解析
    《图解 HTTP》读书笔记
    图解 HTTP 笔记(八)——常见 Web 攻击技术
    图解 HTTP 笔记(七)——HTTPS
  • 原文地址:https://www.cnblogs.com/a1113775906/p/13828467.html
Copyright © 2011-2022 走看看