完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
音乐加显示心的程序如下,音乐是网上做音乐的软件做的,就在里面添加了定时器一,希望能够控制点阵动态扫描,可是加进去点阵可以显示,但音调变长了很多。求助!!!!! #include #define uchar unsigned char ***it beepIO=P1^0; uchar m,n; unsigned char code x[8]={0x18,0x18,0x18,0x18,0x18,0x00,0x38,0x38};/*"未命名文件",0*/ //这句和下面四行是在音乐的程序基础上添加的 unsigned char code y[8]={0x00,0x00,0x00,0x7E,0x00,0x00,0x00,0x00};/*"一",0 */ unsigned char code xin[8]={0x00,0x24,0x5A,0x42,0x24,0x18,0x00,0x00}; unsigned char c=0; unsigned int temp=0x01; 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}, {19,4},{19,4},{19,8},{14,8},{23,4},{23,4},{23,8},{19,8}, {19,4},{23,4},{26,8},{26,8},{24,4},{23,4},{21,16},{21,4},{23,4},{24,8},{24,8}, {23,4},{21,4},{23,8},{19,8},{19,4},{23,4},{21,8},{14,8},{18,4},{21,4},{19,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 timer1() interrupt 3 using 1 //定时器1中断函数 、//这段子程序是添加的 { TH1=(65536-100)/256;//重装初值,同上 TL1=(65536-100)%256; c++;//计数值加1 P0=0xff; P2=xin[c%8]; P0=~(temp<<(c%8)); } void main() { uchar i=0; TMOD=0x11; EA=1; ET0=1; PT0=1; //这句音乐原句是 TMOD=0x01;EA=1;ET0=1; ET1=1;//开定时器1中断 这句和下面三句是添加的 TR1=1;//启动定时器1 TH1=(65536-100)/256;//重装初值,同上 TL1=(65536-100)%256; 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++;} } }
|
|
相关推荐 |
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
6130 浏览 3 评论
7398 浏览 1 评论
7633 浏览 0 评论
Protues中自己封装的芯片元件无Program File、Clock Frequency选项怎么解决,求求大神了!
9426 浏览 1 评论
基于51单片机的车辆倒车雷达报警系统,HC-SR04超声波测距,全套资料
1276 浏览 0 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-24 02:14 , Processed in 0.497607 second(s), Total 71, Slave 53 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号