#include<reg52.h>
sbit ADDR3 = P1^3;
sbit ENLED = P1^4;
unsigned char code LedChar[] = {
0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,
0x80,0x90,0x88,0x83,0xC6,0xA1,0x86,0x8E
};
unsigned char LedBuff[7] = {
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
};
bit flagls = 1;
unsigned char T0RH = 0;
unsigned char T0RL = 0;
void ConfigTimer0(unsigned int ms);
void TrafficLight();
void ConfigUART(unsigned int baud);
unsigned char timer1,timer2,timer3;
unsigned char L;
unsigned char ch1=‘r’,ch2=‘y’,ch3=‘g’;
void main()
{
EA = 1;
ConfigUART(9600);
ENLED = 0;
ADDR3 = 1;
ConfigTimer0(1);
while(1)
{
if(flagls)
{
flagls = 0;
TrafficLight();
if(LedBuff[6]==0xFC) //红
SBUF=ch1;
if(LedBuff[6]==0
智能交通灯————单片机
最新推荐文章于 2024-06-05 14:25:19 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)