- #include<reg51.h>
- #defineuchear unsigned char
- #defineuint unsigned int
- int key,key1;
- sbit LED1=P0^0;
- sbit LED2=P0^2;
- sbit MOTOR=P1^0;
- sbit sky=P3^2;
- sbit sky1=P3^3;
- void main()
- {
- LED1=1;
- LED2=1;
- MOTOR=0;
- EX0=1;
- ES=1;
- IT0=0;
- EX1=1;
- IT1=0;
- EA=1;
- while(1)
- {
- if(key1!=1)
- {
- MOTOR=key;
- LED1=key;
- }
- if(key1==1)
- {
- key=0;
- MOTOR=key;
- LED=key;
- }
- }
- while(1);
- }
- void EX_INT0()interrupt 0
- {
- LED1=0;
- LED2=1;
- MOTOR=1;
- }
- void EX_INT1()interrupt 0
- {
- LED1=1;
- LED2=0;
- MOTOR=0;
- }
复制代码
|