1、- 交通灯的单片机控制设计交通灯的单片机控制设计 摘摘 要要:交通灯安装在各个路口上,成为疏导交通工具有效的手段,单片机是微型 计算机的一个重要分支,特别适用于控制领域,故又称为微控制器,对基于单片机 的交通灯控制系统进行了设计。 本系统采用美国 ATMEL 公司生产的单片机 AT89S52, 以及其它芯片来设计交通灯控制。实现了通过 AT89S52 芯片的 P1 口设置红、绿灯 点亮的功能,通过 AT89S51 芯片的 RXD、TXD 输入、输出设置显示时间。单片机系 统采用的直流供电。系统功能为:以 MCS-51 系列单片机作为控制核心,设计并制 作交通灯控制系统,东西南北四个方向具有左拐
2、、右拐、直行及行人 4 种通行指示 灯,用计时器显示路口通行转换剩余时间,在特种车辆如 119、120 通过路口时, 系统可自动转为特种车辆放行,其他车辆禁止通行状态。 在对系统功能分析的基础上,提出了三种设计方案,经比较,选择性能较优的 LED 动态循环显示方案进行了设计。设计包括硬件和软件两大部分。硬件部分包括 单片机最小系统、时间显示、交通灯显示三部分。选用 Atmel 公司的 AT89S52 单片 机作为控制核心,东西南北四个方向设置了 LED 时间显示和交通灯显示,时间显示 采用三位 LED 显示器,交通灯显示则采用红绿双色高亮发光二极管来模拟。软件采 用了模块化的设计方法,主要分为
3、主程序、定时器中断服务子程序、倒计时显示子 程序、交通灯模拟显示子程序四部分。 在实验板上制作了基于单片机的交通灯控制系统样机,对硬件和软件部分分别 进行了调试,再进行了软硬件联调,得到的交通灯控制系统样机实物,可圆满地完 成毕业设计任务书所要求的功能。 关键词: 交通灯;单片机;AT89S52 Design of traffic light control system based on SCM Abstract: Traffic light control system based on SCM (Single Chip Microcomputer) is designed in this
4、 paper. System requires that MCS-51 series SCM is used as CPU. Traffic light control system should be designed and made .There are four groups light which indicate to turn left, turn right, and go straight ahead and pedestrian access in east, west, north and south four directions. Timer shows traffic conversion remainder time. When special vehicles, such as 119,120 go through, the system can automatically allow special vehicles running and other vehicles is prohibited. Based on analysis of the