#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit key1=P1^6;
sbit key2=P1^7;
char k;
char tt;
void delay(uint m)
{
char i,j;
for(i=m;i>0;i--)
for(j=1000;j>0;j--);
}
void led1(void)//ÕyÏòμãááá÷Ë®μÆ
{
P3=0XFE;
delay(100);
P3=0XFD;
delay(100);
P3=0XFB;
delay(100);
P3=0XF7;
delay(100);
P3=0XEF;
delay(100);
P3=0XDF;
delay(100);
P3=0XBF;
delay(100);
P3=0X7F;
delay(100);
}
void led2(void)//·′Ïòμãááá÷Ë®μÆ
{
P3=0X7F;
delay(100);
P3=0XBF;
delay(100);
P3=0XDF;
delay(100);
P3=0XEF;
delay(100);
P3=0XF7;
delay(100);
P3=0XFB;
delay(100);
P3=0XFD;
delay(100);
P3=0XFE;
delay(100);
}
void main (void)//Ö÷oˉêy
{
TMOD=0X01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;//¿aÆô×üÖD¶Ï
ET0=1;
TR0=1;
P1=0XFF;
while(1)
{
switch(k)
{
case 0:P1=0Xff; break;
case 1:led1(); break;
case 2:led2(); break;
}
}
}
void time(void) interrupt 1
{
TL0=(65536-50000)%256;
TH0=(65536-50000)/256;
if((0xF0&P1)!=0XF0)
{
delay(100);
if(key1==0)
k=1;
if(key2==0)
k=2;
}
}
|