573 latches drive 8-segment digital Tubes
# Include <reg51.h> # define SEG P2 sbit P1_0 = P1 ^ 0; sbit P1_1 = P1 ^ 1; sbit P1_2 = P1 ^ 2; sbit P1_3 = P1 ^ 3; sbit P1_4 = P1 ^ 4; unsigned char code tab [] = {0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x3c, 0x07, 0x7f, 0x37}; // total cathode void delay (int x); void main () {while (1) // 2015 {P1_0 = 0; // 573 low-level enabling SEG = tab [2]; // send the segment P1_1 = 0; // light up the digital tube P1_0 = 1; // close the lock P1_1 = 1; // disable the digital tube P1_0 = 0; // 573 enable SEG = tab [0]; P1_2 = 0; P1_0 = 1; P1_2 = 1; P1_0 = 0; // 573 low-level enabling SEG = tab [1]; P1_3 = 0; P1_0 = 1; P1_3 = 1; P1_0 = 0; // 573 low-level enabling SEG = tab [5]; P1_4 = 0; P1_0 = 1; P1_4 = 1 ;}} void delay (int x) // 6 ms * x 23 MHz crystal oscillator {int I, j; for (I = 0; I <x; I ++) for (j = 0; j <12000; j ++ );}
# Include <reg51.h> # define SEG P2 sbit P1_0 = P1 ^ 0; sbit P1_1 = P1 ^ 1; sbit P1_2 = P1 ^ 2; sbit P1_3 = P1 ^ 3; sbit P1_4 = P1 ^ 4; unsigned char code tab [] = {0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x3c, 0x07, 0x7f, 0x37}; void delay (int x); void main () {while (1) // 521 1314 {P1_0 = 0; // 573 low-level enabling SEG = tab [5]; // send the segment P1_1 = 0; // light up the digital tube delay (166); // delay P1_0 = 1; // disable the lock storage P1_1 = 1; // disable the digital tube P1_0 = 0; // 573 enable SEG = tab [2]; P1_2 = 0; delay (166 ); p1_0 = 1; P1_2 = 1; P1_0 = 0; // 573 low-level enabling SEG = tab [1]; P1_3 = 0; delay (166); P1_0 = 1; p1_3 = 1; //////////////////////////////////////// /// 1314 P1_0 = 0; // 573 low-level enabling SEG = tab [1]; // send the segment P1_1 = 0; // light up the digital tube delay (166); // delay P1_0 = 1; // disable the lock storage P1_1 = 1; // disable the digital tube P1_0 = 0; // 573 enable SEG = tab [3]; P1_2 = 0; delay (166 ); p1_0 = 1; P1_2 = 1; P1_0 = 0; // 573 low-level enabling SEG = tab [1]; P1_3 = 0; delay (166); P1_0 = 1; p1_3 = 1; P1_0 = 0; // 573 low-level enabling SEG = tab [4]; P1_4 = 0; delay (166); P1_0 = 1; p1_4 = 1 ;}} void delay (int x) // 6 ms * x 23 MHz crystal oscillator {int I, j; for (I = 0; I <x; I ++) for (j = 0; j <12000; j ++ );}