51单片机 音乐

祝你平安             

 

 

                0x26,0x20,0x20,0x20,0x20,0x20,0x26,0x10,0x20,

                0x10,0x20,0x80,0x26,0x20,0x30,0x20,0x30,0x20,

                0x39,0x10,0x30,0x10,0x30,0x80,0x26,0x20,0x20,

                0x20,0x20,0x20,0x1c,0x20,0x20,0x80,0x2b,0x20,

                0x26,0x20,0x20,0x20,0x2b,0x10,0x26,0x10,0x2b,

                0x80,0x26,0x20,0x30,0x20,0x30,0x20,0x39,0x10,

                0x26,0x10,0x26,0x60,0x40,0x10,0x39,0x10,0x26,

                0x20,0x30,0x20,0x30,0x20,0x39,0x10,0x26,0x10,

                0x26,0x80,0x26,0x20,0x2b,0x10,0x2b,0x10,0x2b,

                0x20,0x30,0x10,0x39,0x10,0x26,0x10,0x2b,0x10,

                0x2b,0x20,0x2b,0x40,0x40,0x20,0x20,0x10,0x20,

                0x10,0x2b,0x10,0x26,0x30,0x30,0x80,0x18,0x20,

                0x18,0x20,0x26,0x20,0x20,0x20,0x20,0x40,0x26,

                0x20,0x2b,0x20,0x30,0x20,0x30,0x20,0x1c,0x20,

                0x20,0x20,0x20,0x80,0x1c,0x20,0x1c,0x20,0x1c,

                0x20,0x30,0x20,0x30,0x60,0x39,0x10,0x30,0x10,

                0x20,0x20,0x2b,0x10,0x26,0x10,0x2b,0x10,0x26,

                0x10,0x26,0x10,0x2b,0x10,0x2b,0x80,0x18,0x20,

                0x18,0x20,0x26,0x20,0x20,0x20,0x20,0x60,0x26,

                0x10,0x2b,0x20,0x30,0x20,0x30,0x20,0x1c,0x20,

                0x20,0x20,0x20,0x80,0x26,0x20,0x30,0x10,0x30,

                0x10,0x30,0x20,0x39,0x20,0x26,0x10,0x2b,0x10,

                0x2b,0x20,0x2b,0x40,0x40,0x10,0x40,0x10,0x20,             

                0x10,0x20,0x10,0x2b,0x10,0x26,0x30,0x30,0x80,             

                0x00

               

 

 

 

送别

 

 

 

                0x20,40,0x26,20,0x20,20,0x17,80,0x1c,40,0x17,40,

                0x20,80,0x20, 40,0x2f,20,0x2a,20,0x26,40,0x2a,20,

                0x2f,20,0x2a,80,0xff,0x20,40,0x26,20,0x20,20,0x17,60,

                0x19,20, 0x1c,40,0x17,40,0x20,80,0x20,40,0x2a,20,

                0x26,20,0x24,60,0x32,20,0x2f,80,0xff,0x1c,40,0x17,40,

                0x17, 80,0x19,40,0x1c,20,0x19,20,0x17,80,0x1c,20,

                0x19,20,0x17,20,0x1c,20,0x1c,20,0x20,20,0x26,20,0x2f,20,

                0x2a,80,0xff,0x20,40,0x26,20,0x20,20,0x17,60,0x19,20,

                0x1c,40,0x17,40,0x20,80,0x20,40,0x2a,20,0x26, 20,

                0x24,60,0x32,20,0x2f,80,0xff,0x20,40,0x26,20,0x20,20,

                0x17,80,0x1c,40,0x17,40,0x20,80,0x20,40, 0x2f,20,0x2a,20,

                0x26,40,0x2a,20,0x2f,20,0x2a,80,0xff,0x20,40,0x26,20,

                0x20,20,0x17,60,0x19,20,0x1c, 40,0x17,40,0x20,80,0x20,40,

                0x2a,20,0x26,20,0x24,60,0x32,20,0x2f,80,0

 

 

两只蝴蝶

#include <reg51.h>            

#define uchar unsigned char

sbit beepIO=P1^5;                 // 输出 P1.5  可以修改 其它 IO

uchar m,n;

uchar code T[49][2]={{0,0},

{0xF8,0x8B},{0xF8,0xF2},{0xF9,0x5B},{0xF9,0xB7},{0xFA,0x14},{0xFA,0x66},{0xFA,0xB9},{0xFB,0x03},{0xFB,0x4A},{0xFB,0x8F},{0xFB,0xCF},{0xFC,0x0B},

{0xFC,0x43},{0xFC,0x78},{0xFC,0xAB},{0xFC,0xDB},{0xFD,0x08},{0xFD,0x33},{0xFD,0x5B},{0xFD,0x81},{0xFD,0xA5},{0xFD,0xC7},{0xFD,0xE7},{0xFE,0x05},

{0xFE,0x21},{0xFE,0x3C},{0xFE,0x55},{0xFE,0x6D},{0xFE,0x84},{0xFE,0x99},{0xFE,0xAD},{0xFE,0xC0},{0xFE,0x02},{0xFE,0xE3},{0xFE,0xF3},{0xFF,0x02},

{0xFF,0x10},{0xFF,0x1D},{0xFF,0x2A},{0xFF,0x36},{0xFF,0x42},{0xFF,0x4C},{0xFF,0x56},{0xFF,0x60},{0xFF,0x69},{0xFF,0x71},{0xFF,0x79},{0xFF,0x81}

};

uchar code music[][2]={{0,4},

{23,4},{21,4},{23,16},{23,4},{21,4},{23,4},{21,4},{19,16},{16,4},{19,4},{21,8},{21,4},{23,4},{21,4},{19,4},{16,4},{19,4},{14,24},

{23,4},{21,4},{23,16},{23,4},{21,4},{23,4},{21,4},{19,24},{16,4},{19,4},{21,8},{21,4},{23,4},{21,4},{19,4},{16,4},{19,4},{21,24},

{23,4},{21,4},{23,16},{23,4},{21,4},{23,4},{21,4},{19,16},{16,4},{19,4},{21,8},{21,4},{23,4},{21,4},{19,4},{16,4},{19,4},{14,24},

{23,4},{26,4},{26,16},{26,4},{28,4},{26,4},{23,24},{21,4},{23,4},{21,8},{21,4},{23,4},{21,4},{19,4},{16,4},{16,2},{19,2},{19,24},{0,20},

{26,4},{26,4},{28,4},{31,4},{30,4},{30,4},{28,4},{23,4},{21,4},{21,4},{23,16},{0,4},{23,4},{23,4},{26,4},{28,8},{28,12},{16,4},{23,4},{21,4},

{21,24},{23,4},{26,4},{26,4},{23,4},{26,8},{0,4},{31,8},{30,4},{28,4},{30,4},{23,8},{0,4},{28,4},{28,4},{30,4},{28,4},{26,4},{23,4},{21,8},{23,4},{21,4},{23,4},{26,16},

{0xFF,0xFF}};

void delay(uchar p)

{

    uchar i,j;

    for(;p>0;p--)

    for(i=181;i>0;i--)

    for(j=181;j>0;j--);

}

void pause()

{

    uchar i,j;

    for(i=150;i>0;i--)

    for(j=150;j>0;j--);

}

void T0_int() interrupt 1

{

 beepIO=!beepIO;

 TH0=T[m][0]; TL0=T[m][1];

}

void main()

{

 uchar i=0;

 TMOD=0x01;  EA=1; ET0=1;

 while(1)

      {

        m=music[i][0];n=music[i][1];

           if(m==0x00)

             {TR0=0;delay(n);i++;}

           else if(m==0xFF)

             {TR0=0;delay(30);i=0;}

           else if(m==music[i+1][0])

             {TR0=1;delay(n);TR0=0;pause();i++;}

           else

             {TR0=1;delay(n);i++;}

      }

}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Stmlker

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值