From that analysis of the circuit diagram, the need to use digital display system (port P0) and buttons (P1 port)
Analysis system may require
(1) using a digital scroll numbers 1-9
(2) using the control button 1
(3) When the button is pressed to stop scrolling digital numbers, the digital display is a digital to digital lottery.
The preparation of these codes in FIG.
. 1 #include <reg52.h> 2 #define LED_ALL P0 . 3 the sbit Pl ^ KEY = 0 ; . 4 void LED_XUNHUAN (unsigned char led_i) // custom function a cyclic array . 5 { . 6 Switch (led_i) . 7 { . 8 Case 0 : LED_ALL = 0x6F ; BREAK ; // number. 9 . 9 Case . 1: LED_ALL = 0x7F ; BREAK ; // number. 8 10 Case 2 : LED_ALL = 0x07 ; BREAK ; // number. 7 . 11 Case . 3 : LED_ALL = 0x7D ; BREAK ; // number. 6 12 is Case . 4 : LED_ALL = 0x6d ; BREAK ; / / number. 5 13 is Case . 5 : LED_ALL = 0x66 ; BREAK ; // number. 4 14 Case . 6:LED_ALL = 0x4f;break; //数字3 15 case 7:LED_ALL = 0x5b;break; //数字2 16 case 8:LED_ALL = 0x06;break; //数字1 17 } 18 } 19 20 void main(void) 21 { 22 unsigned char i; 23 while(1) 24 { 25 for (I = 0 ; I < . 9 ; I ++ ) 26 is { 27 IF (KEY == 0 ) // determines whether the button is pressed if the cycle stops 28 BREAK ; 29 the else // else continue to loop 30 LED_XUNHUAN ( I); 31 is } 32 } 33 is }
Press the button when the number on the digital display 1 will stop the change, continue to change when the digital release