功能:
带时间显示的红绿灯设计,30秒南北绿灯,东西红灯;3次闪烁黄灯;切换为30秒东西绿灯,南北红灯; 具体定时时间可根据程序自行修改,带有源程序、仿真图。
仿真效果图:
部分程序:
#include #include #define uchar unsigned char uchar led[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; uchar delay(int i) {uchar a,b,c; for(i;i>0;i--) {for(c=167;c>0;c--) for(b=171;b>0;b--) for(a=16;a>0;a--); _nop_; }} void delay1(uchar j) {while(j--); } void huangdeng(uchar i) {while(i--) { P1=0X12; delay(1); P1=0X00; delay(1); } } void dongxi(uchar a) {uchar j=1000; for(a;a>0;a--) { while(j--) {P1=0X24; P0=0XFE; P2=led[a/10]; delay1(1000); P0=0XFd; P2=led[a%10]; delay1(1000); }} P0=0XFF; } void nanbei(uchar a) {uchar j=1000; for(a;a>0;a--) {
相关文章









