Proteus
仿真原理图:
Keil C源程序:
#include
#define uchar unsigned char
#define uint unsigned int
sbit RED_DONGXI = P1^0;//南北方向红灯亮
sbit YELLOW_DONGXI = P1^1;//南北方向黄灯亮
sbit RED_NANBEI = P1^3;//东西方向红灯亮
sbit GREEN_DONGXI = P1^2;//南北方向绿灯亮
sbit YELLOW_NANBEI = P1^4;//东西方向黄灯亮
sbit GREEN_NANBEI = P1^5;//东西方向绿灯亮
sbit DXweixuan1 = P1^6;//南北方向数码管位选1
sbit DXweixuan2 = P1^7;//南北方向数码管位选2
sbit NBweixuan1 = P3^0;//东西方向数码管位选1
sbit NBweixuan2 = P3^1;//东西方向数码管位选2
sbit L1=P3^5;
sbit L2=P3^6;
sbit L3=P3^7;
uint aa, bai,shi,ge,bb;
uint shi1,ge1,shi2,ge2;
uint code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; uint code table1[]={0xfc,0x60,0xda,0xf2,0x66,0xb6,0xbe,0xe0,0xfe,0xf6};
void delay(uint z);
void init(uint a);
void display(uint shi1,uint ge1,uint shi2,uint ge2);
void xtimer0();
void init1();
void init2();
void init3();
void init4();
void init5();
void xint1();
void xint0();
void LED_ON();
void LED_OFF();
void main()