单片机案例开发——交通灯设计

2019-04-15 17:08发布

#include #define uchar unsigned char #define uint unsigned int sbit FMQ=P3^4; sbit QR=P2^7; sbit QY=P2^6; sbit QG=P2^5; sbit HR=P2^7; sbit HY=P2^6; sbit HG=P2^5; sbit ZR=P2^4; sbit ZY=P2^3; sbit ZG=P2^2; sbit YR=P2^4; sbit YY=P2^3; sbit YG=P2^2; sbit SWITCH1=P1^0; sbit SWITCH2=P1^1; sbit SWITCH3=P1^2; sbit SWITCH4=P1^3; sbit P3_2=P3^2; sbit P3_3=P3^3; uchar DAT1,DAT2; //显示时间变量 uchar DISP1[2]={0,0}; //显示缓冲区1,南北 uchar DISP2[2]={0,0}; //显示缓冲区2,东西 uchar code table[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0xFF}; void DISPCLK1(uchar i); void DISPCLK2(uchar i); void DEL1MS(uint z) { uint x,y; for(x=0;x