资源预览内容
第1页 / 共9页
第2页 / 共9页
第3页 / 共9页
第4页 / 共9页
第5页 / 共9页
第6页 / 共9页
第7页 / 共9页
第8页 / 共9页
第9页 / 共9页
亲,该文档总共9页全部预览完了,如果喜欢就下载吧!
资源描述
51单片机键盘、点阵程序点阵程序#include unsigned char tabx=0xf7,0xf7,0x80,0xf7,0xf7,0xff,0xff,0xff, 0xf7,0xf7,0x80,0xf7,0xf7,0xff,0xff,0xff, 0xf7,0xf7,0x80,0xf7,0xf7,0xff,0xff,0xff, 0xff,0xf7,0xf7,0x80,0xf7,0xf7,0xff,0xff, 0xff,0xff,0xf7,0xf7,0x80,0xf7,0xf7,0xff, 0xff,0xff,0xf7,0xf7,0x80,0xf7,0xf7,0xff, 0xff,0xff,0xff,0xf7,0xf7,0x80,0xf7,0xf7 ; unsigned char taby=0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f, 0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f, 0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f, 0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f, 0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f, 0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f, 0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f;unsigned char i,j,k;unsigned int a,b; void delay(unsigned int z ) for(a=z;a0;a-) for(b=110;b0;b-); void display() while(1) P1=tabyi; P0= tabxj; delay(5); P0=0X00; P1=0XFF; i+; if(i=56) i=0; j+; if(j%16)=0) delay(10); if(j%56)=0) delay(500); if(j=56) delay(200); j=0; void main() while(1) display(); delay(5); 键盘程序#includereg51.hsbit key1 = P37;sbit key2 = P36;sbit key3 = P35;sbit key4 = P34;sbit key5 = P33;sbit key6 = P32;sbit led1 = P20;sbit led2 = P21;sbit led3 = P22;sbit led4 = P23;#define uchar unsigned char uchar i;void main(void) while(1) if (key1=0) led1=0; led2=1; if (key2=0) led1=1; led2=0; if (key3=0) led3=0; led4=0; if (key4=0) led3=1; led4=1; if (key5=0) led1=0; led2=0; led3=0; led4=0; if (key6=0) led1=1; led2=1; led3=1; led4=1; 闪烁灯#includesbit P1_0=P10; void delay02s(void) unsigned char i,j,k; for(i=20;i0;i-) for(j=20;j0;j-) for(k=248;k0;k-); void main(void) while(1) P1_0=0; delay02s(); P1_0=1; delay02s(); 流水灯#include #include unsigned char a,b,k,j;sbit beep=P23;void delay10ms() for(a=100;a0;a-) for(b=225;b0;b-); void main() k=0xfe; while(1) delay10ms(); beep=0; delay10ms(); beep=1; j=_crol_(k,1); k=j; P1=j;
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号