单片机控制交通灯

上传人:沈*** 文档编号:78581336 上传时间:2022-04-22 格式:DOC 页数:3 大小:27.88KB
返回 下载 相关 举报
单片机控制交通灯_第1页
第1页 / 共3页
单片机控制交通灯_第2页
第2页 / 共3页
单片机控制交通灯_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述
#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) 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();
展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 办公文档


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!