#include<reg52.h>
#define uint unsigned int #define uchar unsigned char #define SEG P0//(P0.0开始一场接入a-h) #define WE P2 // (P2.0开始依次接入1-4)
void delay (uint z) { uint x,y; for(x = z;x > 0;x--) for(y = 110;y > 0;y--) {
} } void display_led(uchar WEI,uchar NUM) { uchar code scandate[] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; uchar code bitdate[] = {0xf7,0xfb,0xfd,0xfe}; WE = bitdate[WEI-1]; delay(5); SEG = scandate[NUM]; }
void main(void) { SEG = 0x00; WE = 0xff; while(1) { display_led(1,8); display_led(2,8); display_led(3,8); display_led(4,8); }}
|