1、 摘 要 本次设计的题目是基于单片机的交通灯设计,系统主要由单片机 AT89S52 控制,实现 数据存储,并结合外围的键盘输入、LED 显示等电路模块,实现相关的功能。所设计的系 统能完成以下功能:甲车道和乙车道两条交叉道路上的车辆交替运行,甲车道为主车道, 每次通车时间为 60 秒,乙车道为次车道,每次通车时间为 30 秒,要求黄灯亮 3 秒,并且 1 秒闪烁一次。有应急车辆出现时,红灯全亮,应急车辆通车时间 10 秒,同时禁止其他车 辆通过。这是生活中很常见的现象,同时本设计有成本低,易操作,实用等特点。 关键词: 单片机;交通灯;LED 显示 ABSTRACT The topic of
2、this design is based on the Single chip microcomputer of traffic light design, the system is mainly composed of single chip microcomputer AT89S52 control to realize data storage, and combined with peripheral keyboard input LED display circuit module, realize the function design of the system can com
3、plete the following functions: a lane and b lane two cross road vehicle alternating operation, a lane is given priority to lane, every time to traffic time for sixty seconds, b lane as a lane, every time to traffic time for 30 seconds for yellow light for 3 seconds, and 1 second flicker a emergency
4、vehicle appeared, the red light full bright, emergency vehicle traffic time 10 seconds, and to ban other vehicles through this life is very common phenomenon, at the same time the design has low cost, easy to operate, practical characteristics. Key WordsKey Words: Single chip microcomputer; Traffic
5、lights; LED Display 目 录 1 设计要求及总体方案介绍 . 3 1.1 设计课题任务 . 1 1.2 功能说明 . 1 1.3 设计总体方案介绍及工作原理说明 . 2 1.3.1 总体方案介绍 2 1.3.2 工作原理 3 2 硬件系统的设计 . 4 2.1 硬件系统各模块功能介绍 . 4 2.1.1 显示电路 4 2.1.3 键盘控制电路 4 2.1.4 时钟电路 5 2.1.5 复位电路 5 2.1.6 流水灯电路 . 5 2.1.7 下载口电路 5 2.2 电路原理图 . 6 2.3 电路 PCB 图 . 6 2.4 元器件布局图 . 6 2.5 元器件清单 . 6
6、3 软件系统的设计 . 7 3.1 单片机的使用资源情况 . 7 3.1.1 资源使用说明 7 3.2 软件模块功能介绍 . 8 3.3 程序流程图 . 8 3.3.1 主程序的流程框图 8 3.3.2 键扫子程序流程框图 8 3.3.3 显示子程序流程框图 8 4 设计调试与分析 11 4.1 使用说明 . 11 4.2 硬件性能的检测 . 11 4.3 程序调试. 11 4.3 误差分析 12 4.4 设计体会及教学意见 12 结束语 . 13 致 谢 . 14 参考文献 . 15 附 录 . 16 附录一 电路原理图 . 16 附录二 PCB 图 17 附录三 元器件布局图 . 18 附录四 交通灯元器件清单 . 19 附录五 实物图 . 19 附录六 程序清单 . 20 1 设计要求及总体方案介绍 1.1 设计课题任务 设计一个具有特定功能的十字路口交通灯。该交通灯上电或按键复位后能自动显示系 统提示符“P.”, 进入准备工作状态。 按开始键则开始工作, 按结束键则返回“P.”状态。 要求甲车道和乙车道两条交叉道路上的车辆交替运行,甲车道为主车道,每次通车时间为 60 秒,