添加了数码管,循环显示0-9
按键触发中断点亮对应的LED灯
有个问题就是不能同时点亮两个,也就是说按键一次,必须弹起来再按另外一个才行,呵呵。
程序如下:
void main()
{
uchar yyy;
IT0 = 1;//下降沿触发
EX0 = 1;//分中断开关打开
EA = 1;//总中断开关打开
while(1)
{
led_display_xunhuan();
}
}
void delay_50ms(unsigned int t) // t="10", 500ms; t="100", 5s;
{
uint j;
for(;t>0;t--)
for(j=6245;j>0;j--);
}
void led_display_xunhuan()
{
P0 = 0xc0;
delay_50ms(10);
P0 = 0xf9;
delay_50ms(10);
P0 = 0xa4;
delay_50ms(10);
P0 = 0xb0;
delay_50ms(10);
P0 = 0x99;
delay_50ms(10);
P0 = 0x92;
delay_50ms(10);
P0 = 0x82;
delay_50ms(10);
P0 = 0xf8;
delay_50ms(10);
P0 = 0x80;
delay_50ms(10);
P0 = 0x90;
delay_50ms(10);
}
void Scan_Key (void) interrupt 0
{
IE0 = 0;
P1 = P2;
}
用户124183 2009-7-31 09:13