单片机控制交通灯

上传人:夏** 文档编号:454833904 上传时间:2023-06-08 格式:DOC 页数:3 大小:27.85KB
返回 下载 相关 举报
单片机控制交通灯_第1页
第1页 / 共3页
单片机控制交通灯_第2页
第2页 / 共3页
单片机控制交通灯_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

《单片机控制交通灯》由会员分享,可在线阅读,更多相关《单片机控制交通灯(3页珍藏版)》请在金锄头文库上搜索。

1、#include#define uchar unsigned char #define uint unsigned intsbit RED_A=P00;sbit YELLOW_A=P01;sbit GREEN_A=P02;sbit RED_B=P03;sbit YELLOW_B=P04;sbit GREEN_B=P05;uchar flash_count=0;operation_type=1;void delayms(uint x) uchar i; while (x-) for (i=0;i120;i+);void traffic_light() switch(operation_type)

2、 case 1:RED_A=1;YELLOW_A=1;GREEN_A=0; RED_B=0;YELLOW_B=1;GREEN_B=1; delayms(2000); operation_type=2; break; case 2:delayms(300); YELLOW_A=!YELLOW_A;GREEN_A=1; if (+flash_count!=10) return; flash_count=0; operation_type=3; break; case 3:RED_A=0;YELLOW_A=1;GREEN_A=1; RED_B=1;YELLOW_B=1;GREEN_B=0; delayms(2000); operation_type=4; break; case 4:delayms(300); YELLOW_B=!YELLOW_B;GREEN_B=1; if (+flash_count!=10) return; flash_count=0; operation_type=1; void main() while(1) traffic_light();

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 大杂烩/其它

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号