交通灯十字路口控制器程序(共35页).doc
《交通灯十字路口控制器程序(共35页).doc》由会员分享,可在线阅读,更多相关《交通灯十字路口控制器程序(共35页).doc(35页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、精选优质文档-倾情为你奉上#include#define uchar unsigned char#define uint unsigned intuchar code table=0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x40;/*digit display port*sbit led_w1=P11;sbit led_w2=P10;sbit led_w3=P13;sbit led_w4=P12;/*define led port *sbit R1=P24; /east and west red ledsbit Y1=P23; /ea
2、st and west yellow ledsbit G1=P22; /east and west green ledsbit R2=P25; /south and north red ledsbit Y2=P26; /south and north yellow ledsbit G2=P27; /south and north green led/*define key*sbit k0=P30; /emergencysbit k1=P31; /east and west passsbit k2=P32; /south and north passsbit k3=P33; /start and
3、 subtract 1sbit k4=P34; /pause and add 1sbit k5=P35; /set time/*define variable*bit flag,flag_t;uchar dx_time,nb_time;uchar cnt,pass_time,cnt1,y_time;uchar k0num,k1num,k2num,k3num,k4num,k5num;/*define key*void delay(uint i)uint x,y;for(x=i;x0;x-)for(y=110;y0;y-); void timer0_init()TMOD=0x11;TH0=(655
4、36-50000)/256;TL0=(65536-50000)%256;TH1=(65536-50000)/256;TL1=(65536-50000)%256;EA=1;ET0=1;ET1=1;void led_display(uchar dx,nb)uchar dx1,dx2,nb1,nb2;dx2=dx/10;dx1=dx%10;nb2=nb/10;nb1=nb%10;if(dx99)led_w1=1;led_w2=1;elseled_w1=0;P0=tabledx1;delay(5);led_w1=1;if(dx0) led_w2=1;elseled_w2=0;P0=tabledx2;d
5、elay(5);led_w2=1;if(nb99)led_w3=1;led_w4=1;elseled_w3=0;P0=tablenb1;delay(5);led_w3=3;if(nb0) led_w4=1;elseled_w4=0;P0=tablenb2;delay(5);led_w4=4;/*light work*void circle_led()if(!flag)if(pass_time5)led_display(pass_time-5,pass_time);R1=1;Y1=1;G1=0;/east and west passR2=0;Y2=1;G2=1;/south and north
6、stopif(pass_time0)if(cnt=10) led_display(pass_time,pass_time);else led_display(100,pass_time);R1=1;G1=1; /east and west yellow led flashif(cnt=10)Y1=0;else Y1=1;R2=0;Y2=1;G2=1;if(pass_time=0)pass_time=nb_time;flag=1;elseif(pass_time5)led_display(pass_time,pass_time-5);R1=0;Y1=1;G1=1;/east and west s
7、topR2=1;Y2=1;G2=0;/south and north passif(pass_time0)if(cnt=10) led_display(pass_time,pass_time);else led_display(pass_time,100);R1=0;Y1=1;G1=1;R2=1;G2=1; /south and north yellow led flashif(cnt=10)Y2=0;else Y2=1;if(pass_time=0)pass_time=dx_time;flag=0;void emergency() /east and west,south and north
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 交通灯 十字路口 控制器 程序 35
限制150内