1、 单片机模拟交通灯的设计单片机模拟交通灯的设计 摘 要 本设计是依据数字集成电路、单片机技术为基础,采用 MCS-51 系列单片机 AT89C51 为控制器件结合 LED 数码显示电路、 发光二极管指示电路组成交通灯硬件电路, 利用单片 机内部定时中断溢出产生 1s 实现倒计时。系统能够完成 25s 倒计时显示,在倒计时到 5s 时绿灯开始闪烁以提醒过往的车辆及行人安全通行,倒计时到 2s 时黄灯亮。 关键词:单片机;AT89C51;交通灯 ABSTRACT This design is based on digital integrated circuits, microcontroller
2、 technology, the use of MCS-51 series microcontroller AT89C51 devices for the control circuit with LED digital display, LED traffic lights indicating hardware circuit, the use of internal microcontroller timer interrupt overflow 1s achieved countdown. System can accomplish the 25s countdown, the cou
3、ntdown to when the green light starts flashing 5s to alert passing vehicles and pedestrians safe passage, the countdown to when the yellow light 2s. Keywords: SCM;AT89C51;Traffic lights 目 录 1 绪论绪论 1 1.1 研究背景研究背景 . 1 1.2 单片机的概述单片机的概述 . 1 1.3 单片机的应用单片机的应用 . 2 1.4 单片机的发展史单片机的发展史. 2 2 系统硬件设计系统硬件设计 3 2.1
4、 系统原理系统原理 . 3 2.2 AT89C51 的介绍的介绍 4 2.3 AT89C51 的引脚说明的引脚说明 5 2.4 时钟电路时钟电路 . 7 2.5 复位电路复位电路 . 7 2.6 单片机的最小系统构成单片机的最小系统构成. 8 2.7 7405 TTL 集电极开路六反相器集电极开路六反相器 8 2.8 指示电路指示电路 . 8 2.9 LED 数码显示器数码显示器 9 3 系统软件设计系统软件设计 11 3.1 系统整体程序流程图系统整体程序流程图. 11 3.2 设置定时,显示初始化设置定时,显示初始化. 11 3.3 处理状态、倒计时显示处理状态、倒计时显示. 13 3.4 路口红绿灯状态子程序路口红绿灯状态子程序. 14 3.5 LED 显示子程序显示子程序 14 4 系统仿真系统仿真 16 4.1 仿真平台介绍仿真平台介绍 . 16 4.1.1 Keil 软件介绍软件介绍 16 4.1.2 Proteus 仿真软件介绍仿真软件介绍 17 4.2 系统硬件实现系统硬件实现 . 19 4.3 系统仿真及分析系统仿真及分析. 19 5 总结总结 22 参考文