|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
- 51单片机--按键控制LED灯点亮(按两次)
- #include <reg51.h>
- unsigned char led0[]={0xfe,0xfe,0xfd,0xfd,0xfb,0xfb,0xf7,0xf7,0xef,0xef,0xdf,0xdf,0xbf,0xbf,0x7f,0x7f,0x7f};
- unsigned char led1[]={0xff,0xff};
- unsigned char count=0;
- void unit()
- {
- IT1=1;
- EX1=1;
- EA=1;
- }
- void main()
- {
- unit();
- while(1)
- {
- if(count>16)
- count=1;
-
- if(count<2)
- {
- P0=led1[count];
- }
- else
- {
- P0=led0[count-2];
- }
- }
- }
- void inty() interrupt 2
- {
- count++;
- }$ w0 ^1 q% X0 d+ k8 s( C$ s$ F
9 G) X( R/ e- s* a% ]- \$ P( y$ b |
|