资源描述:
《单片机技能大赛编程大全.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、一.开关检测器程序编写:ORG00HSTART:MOVA,P1ANLA,#0F0HRRARRARRARRAORlA,#0F0HMOVP1,ASJMPSTARTORG00HSTART:MOVA,P1ANLA,#0F0HRRARRARRARRAORlA,#0F0HMOVP1,ASJMPSTART二:节日彩灯控制器编程:#include#defineucharunsignedchar#defineuintunsignedintsbitkey=P1^2;ucharcodetable_P0[]={0xfc,0xf9,0xf3,0xe7,0xcf,0x9f,0x3f,0
2、x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe7,0xdb,0xbd,0x7e,0xbd,0xdb,0xe7,0xff,0xe7,0xc3,0x81,0x00,0x81,0xc3,0xe7,0xff,0xaa,0x55,0x18,0xff,0xf0,0x0f,0x00,0xff,0xf8,0xf1,0xe3,0xc7,0x8f,0x1f,0x3f,0x7f,0x7f,0x3f,0x1f,0x8f,0xc7,0xe3,0xf1,0xf8,0xff,0x00,0x00,0xff,0xff,0x0f,0xf0,0xff,0xfe,0x
3、fd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xc0,0xe
4、0,0xf0,0xf8,0xfc,0xfe,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff};ucharcodetable_P2[]={0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0xfc,0xf9,0xf3,0xe7,0xcf,0x9f,0x3f,0xff,0xe7,0xdb,0xbd,0x7e,0xbd,0xdb,0xe7,0xff,0xe7,0xc3,0x81,0x00,0x81,0xc3,0xe7,0xff,0xaa,0x55,0x18,0xff,0xf0,0x0f,0x00,0xff,0xf8,0x
5、f1,0xe3,0xc7,0x8f,0x1f,0x3f,0x7f,0x7f,0x3f,0x1f,0x8f,0xc7,0xe3,0xf1,0xf8,0xff,0x00,0x00,0xff,0xff,0x0f,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf
6、f,0xff,0xff,0xff,0xff,0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00,0x00,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff};//延时voiddelay(uintxms){uinti,j;for(i=xms;i>0;i--)for(j=110;j>0;j--);}//主程序voidmain(){uchari;if(key==0){delay
7、(10);if(key==0){while(!key);while(1){//从数组中读取数据送至P0和P2口显示for(i=0;i<136;i++){P0=table_P0[i];P2=table_P2[i];delay(100);}}}}}三.简单的左右循环流水灯的制作#include#includeunsignedchartemp;//定义字符变量temp,temp左移或右移并给连接LED的P1口赋值inta;//定义延迟函数delay()voiddelay