完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
`最近刚用at89s52单片机做了摇摇棒,遇到了些问题,程序烧写上不显示英语字母,只显示汉字,而且汉字也不完整,真心求帮助 # include # include /********************************************************** 程序名称:LED摇摇棒显示64*16像素 简要说明:外部中断方式INT0显示;取模方式:纵向取模、字节倒序 编 写:lisongze 最后更新:12/12/12 **********************************************************/ #define uchar unsigned char #define uint unsigned int //宏定义 #define KEY P3_0 //定义画面切换按键 uchar KY; //KY作用在后面说明 uchar disp; //显示汉字指针 uchar pic=0,num=0; //pic为按键次数;num为中断次数 uchar code love[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x3F,0x00,0x20,0x00,0x20,0x00,0x20, 0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x0F, 0x04,0x10,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x04,0x10,0xF8,0x0F,0x00,0x00, 0x00,0x00,0x00,0x00,0xFE,0x07,0x00,0x08,0x00,0x10,0x00,0x20,0x00,0x20,0x00,0x10, 0x00,0x08,0xFE,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x3F,0x82,0x20,0x82,0x20, 0x82,0x20,0x82,0x20,0x82,0x20,0x82,0x20,0x82,0x20,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*LOVE*/ }; uchar code loveyou[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x78,0x00,0xFC,0x00,0xFE,0x01,0xFE,0x03,0xFE,0x07,0xFE,0x0F,0xFE,0x1F,0xFC,0x3F, 0xF8,0x7F,0xFC,0x3F,0xFE,0x1F,0xFE,0x0F,0xFE,0x07,0xFE,0x03,0xFE,0x01,0xFC,0x00, 0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*心形图案*/ }; uchar code hehe[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x01,0x40,0x01,0xC0,0x01,0x00,0x00,0x00,0x00, 0xF0,0x0F,0x08,0x10,0x04,0x20,0x00,0x00,0x00,0x00,0xF0,0x3F,0x08,0x00,0x04,0x00, 0x04,0x00,0x04,0x00,0x08,0x00,0xF0,0x3F,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x20, 0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x00,0x00,0x00,0xF0,0x3F,0x08,0x00,0x04,0x00, 0x04,0x00,0x04,0x00,0x08,0x00,0xF0,0x3F,0x00,0x00,0x00,0x00,0x04,0x20,0x08,0x10, 0xF0,0x0F,0x00,0x00,0x00,0x00,0xC0,0x01,0x40,0x01,0xC0,0x01,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*呵呵o(∩_∩)o图案*/ }; unsigned char code hanzi[] = { /*欣*/ 0x00,0x40,0x00,0x30,0xFC,0x0F,0x44,0x00, 0x44,0x00,0xC2,0x7F,0x43,0x80,0x42,0x40, 0x20,0x30,0x1F,0x0C,0xD0,0x03,0x10,0x0C, 0x10,0x30,0x50,0xC0,0x30,0x40,0x00,0x00, /*欣*/ 0x00,0x40,0x00,0x30,0xFC,0x0F,0x44,0x00, 0x44,0x00,0xC2,0x7F,0x43,0x80,0x42,0x40, 0x20,0x30,0x1F,0x0C,0xD0,0x03,0x10,0x0C, 0x10,0x30,0x50,0xC0,0x30,0x40,0x00,0x00, /*我*/ 0x20,0x00,0x24,0x08,0x24,0x48,0x24,0x84, 0xFE,0x7F,0x23,0x02,0x22,0x21,0x20,0x10, 0xFF,0x09,0x20,0x06,0x22,0x1A,0xAC,0x61, 0x20,0x80,0x30,0xE0,0x20,0x00,0x00,0x00, /*爱*/ 0x40,0x00,0xB0,0x00,0x92,0x40,0x96,0x30, 0x9A,0x8C,0x92,0x83,0xF2,0x46,0x9E,0x2A, 0x92,0x12,0x91,0x2A,0x99,0x26,0x95,0x42, 0x91,0xC0,0x50,0x40,0x30,0x00,0x00,0x00, /*你*/ 0x40,0x00,0x20,0x00,0xF8,0xFF,0x07,0x00, 0x40,0x00,0x20,0x08,0x18,0x04,0x0F,0x43, 0x08,0x80,0xC8,0x7F,0x08,0x00,0x08,0x01, 0x28,0x06,0x18,0x0C,0x00,0x00,0x00,0x00 }; /*****函数声明*****/ void display1(void); void display2(void); void display3(void); void display4(void); /*****n(us)延时子程序*****/ void DelayUs(uint N) { uint x; for(x=0; x<=N;x++); } /*****中断服务程序*****/ void intersvr0(void) interrupt 0 using 1 { KY=~KY; //每个摇动来回水银开关会在摆幅两端分别产生下降沿中断,只提取其中一次(从左向右摇才显示) if(KY==0) //初始值为0,每一次翻转一次,两次只相应一次 { num++; //计算中断次数 switch(pic) //选择画面 初始值为0 { case 0:{display1();}break; case 1:{display2();}break; case 2:{display3();}break; case 3:{display4();}break; default:{display1();} //特殊情况显示画面一 } } } void display1(void) { uchar i; if(num>10){disp++;num=0;} //12个汉字分为3次显示完(每次显示4个),每中断10次切换 if(disp>1)disp=0; //DelayUs(5200); //此处延时时间依各硬件差别而各不相同,试着调整使得显示内容居中即可 DelayUs(4500); switch(disp) { case 0: for (i=0;i<32;i++){ P0=~hanzi[i*2]; P2=~hanzi[i*2+1]; DelayUs(100); } break; case 1: for (i=0;i<48;i++){ P0=~hanzi[64+i*2]; P2=~hanzi[64+i*2+1]; DelayUs(100); } break; } } /*****显示子程序2(LOVE)*****/ void display2(void) { uchar i; DelayUs(4000); for(i=0;i<64;i++) { P0=~love[i*2]; P2=~love[i*2+1]; DelayUs(120); } } /*****显示子程序3(心形图案)*****/ void display3(void) { uchar i; DelayUs(4000); for(i=0;i<64;i++) { P0=~loveyou[i*2]; P2=~loveyou[i*2+1]; DelayUs(120); } } /*****显示子程序4(呵呵o(∩_∩)o图案)*****/ void display4(void) { uchar i; DelayUs(4000); for(i=0;i<64;i++) { P0=~hehe[i*2]; P2=~hehe[i*2+1]; DelayUs(120); } } /*****主函数*****/ void main(void) { IT0=1; EX0=1; EA=1; //开中断,下降沿中断 KY=0; while(1) //主程序中只检测按键 { if(KEY==0) //画面切换键按下 { DelayUs(20000); //按键去抖 if(KEY==0); pic++; } if(pic>3)pic=0; } } /*****END*****/ ` |
|
相关推荐
4 个讨论
|
|
只有小组成员才能发言,加入小组>>
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-24 17:15 , Processed in 0.764948 second(s), Total 50, Slave 39 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号