89C51单片机C语言用四个74hc595控制四个LED实现交通灯
(2009-05-16 18:52:38)
标签:
教育
#include
#define uchar unsigned char
#define uint unsigned int
uint t1oc=20; //20*50000us=1s
uint count;
uchar tp[8];
uchar t1,t2,t3,t4;
uchar d1,d2,d3,d4;
//数码管显示代码
unsigned char code tab[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71,
0x40,0x80};
//0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
//0 1 2 3 4 5 6 7 8 9 A B C D E F - .
unsigned char code tab_p[]={
0xbf,0x86,0xdb,0xcf,
0xe6,0xed,0xfd,0x87,
0xff,0xef,0xf7,0xfc,
0xb9,0xde,0xf9,0xf1};//带小数点的16个数码
unsigned char code tab_w[]={
0x7F,0xBF,0xDF,0xEF,0xF7,0xfb,0xfd,0xfe};//位选择代码 从右到左
void delay1ms(un