220 [Completed Course Design] Design of Intelligent Traffic Light System Based on 51 Single-chip Microcomputer-LED-Infrared Obstacle Avoidance

[Resource Download] The download address is as follows:
https://docs.qq.com/doc/DTlRSd01BZXNpRUxl

51 Intelligent Traffic Light System Design-LED-Infrared Obstacle Avoidance-Voice-LCD1602

The design is composed of STC89C52 single-chip circuit + led lamp circuit + infrared obstacle avoidance sensor circuit + LCD1602 liquid crystal display circuit + voice module circuit + power supply circuit.

1. When the infrared obstacle avoidance sensor detects an obstacle, after 15 seconds, the red LED1 will be on and the green LED1 will not be on. The red LED2 is off and the green LED2 is on. At the same time, the voice only broadcasts: Please pay attention to the safety of pedestrians crossing the road. After 15 seconds, the red LED1 is off and the green LED1 is on. The red LED2 is on, the green LED2 is off, and the voice only broadcasts: please wait patiently. And cycle in turn.

2. The LCD displays the countdown time in real time.

3. When the infrared obstacle avoidance sensor does not detect an obstacle, the red LED1 is off and the green LED1 is on. The red LED2 is on, and the green LED2 is off.

4. By default, the red LED1 is off and the green LED1 is on. The red LED2 is on, and the green LED2 is off.

#include<reg52.h> //包含头文件,一般情况不需要改动,头文件包含特殊功能寄存器的定义
#include<stdio.h>
#include "delay.h"
#include "1602.h"

sbit led_red1 =P1^0;  //引脚定义
sbit led_gre1 =P1^1;  
sbit led_red2 =P1^3;  
sbit led_gre2 =P1^2;  
sbit yy1 =P1^4; 
sbit yy2 =P1^5;

sbit hotm = P3^2;

char dis0[16];			   //打印数组初始化
char dis1[16];			   //打印数组初始化

unsigned long time_20ms=0;		   //定时器计数

unsigned int yunTime = 0;   //运行时间
unsigned char runStep = 1; //运行步骤

bit disFlag  = 0; //定时更新显示

void Init_Timer0(void);
void uartSendStr(unsigned char *s,unsigned char length);
void UART_Init(void);
void uartSendByte(unsigned char dat);

void main (void)

 

Guess you like

Origin blog.csdn.net/theroadon/article/details/109232079