仿真结果是红灯会亮30秒,黄灯5秒,绿灯20秒,每个led在最后5秒都会闪烁。按下中断按键是直接全灭(包括倒数数码管),按复位键即可重新开机。
代码
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit red=P0^0;
sbit yellow=P0^1;
sbit green=P0^2;
uint x,y;
uchar i;
uchar count;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
/*ÑÓ³Ùº¯Êý*/
void delay(uint time)
{
for(x=time;x>0;x--)
{
for