Home > categories > Lights & Lighting > Advertising Lights > Advertising lights left shift to the right microcontroller program
Question:

Advertising lights left shift to the right microcontroller program

Advertising lights left shift to the right microcontroller program

Answer:

The eight light emitting diodes L1 L8 respectively connected to the P1.0 MCU and P1.7 interface, the output is "0", the LED light at the beginning of P1.0 - P1.1 - P1.2 - P1.3 -, - P1.7 - P1.6 - P1.0, and bright, repeat, this is a compilation of crystal 12M:: ORG 0 START: MOV R2. #8 MOV A, #0FEH SETB C LOOP: MOV P1, A LCALL DELAY RLC A DJNZ R2, LOOP MOV R2, #8 LOOP1: MOV P1, A LCALL DELAY RRC A DJNZ R2, LOOP1 LJMP START DELAY: MOV R5, D1: MOV R6, #20 #20; D2: MOV R7, #248 DJNZ R7, $DJNZ R6, D2 DJNZ R5 D1 RET END, of course, also can use C language to write: #include #include // #define uint unsigned int contains the displacement function of #define uchar unsigned char uchar temp I; / / data type unsigned char 8 void delay (uint); void (main) {temp=0xfe; P1=temp; while (1) {fo R (i=0; i<8; i++) {temp=_cror_ (temp, 1); / / the right one delay (800); / / set the delay time P1=temp;} for (i=0; i<8; i++) {temp=_crol_ (temp, 1); / / left a delay (800); / / set the delay time P1=temp;}}} void (delay uint z) uint y {/ / delay procedures; (for; z>0; z--) for (y=248; y>0; y--;})
The eight light emitting diodes L1 L8 respectively connected to the P1.0 MCU and P1.7 interface, the output is "0", the LED light at the beginning of P1.0 - P1.1 - P1.2 - P1.3 -, - P1.7 - P1.6 - P1.0, and bright, repeat, this is a compilation of crystal 12M:: ORG 0 START: MOV R2. #8 MOV A, #0FEH SETB C LOOP: MOV P1, A LCALL DELAY RLC A DJNZ R2, LOOP MOV R2, #8 LOOP1: MOV P1, A LCALL DELAY RRC A DJNZ R2, LOOP1 LJMP START DELAY: MOV R5, D1: MOV R6, #20 #20; D2: MOV R7, #248 DJNZ R7, $DJNZ R6, D2 DJNZ R5 D1 RET END, of course, also can use C language to write: #include #include // #define uint unsigned int contains the displacement function of #define uchar unsigned char uchar temp I; / / data type unsigned char 8 void delay (uint); void (main) {temp=0xfe; P1=temp; while (1) {fo R (i=0; i<8; i++) {temp=_cror_ (temp, 1); / / the right one delay (800); / / set the delay time P1=temp;} for (i=0; i<8; i++) {temp=_crol_ (temp, 1); / / left a delay (800); / / set the delay time P1=temp;}}} void (delay uint z) uint y {/ / delay procedures; (for; z>0; z--) for (y=248; y>0; y--;})
The eight light emitting diodes L1 L8 respectively connected to the P1.0 MCU and P1.7 interface, the output is "0", the LED light at the beginning of P1.0 - P1.1 - P1.2 - P1.3 -, - P1.7 - P1.6 - P1.0, and bright, repeat, this is a compilation of crystal 12M:: ORG 0 START: MOV R2. #8 MOV A, #0FEH SETB C LOOP: MOV P1, A LCALL DELAY RLC A DJNZ R2, LOOP MOV R2, #8 LOOP1: MOV P1, A LCALL DELAY RRC A DJNZ R2, LOOP1 LJMP START DELAY: MOV R5, D1: MOV R6, #20 #20; D2: MOV R7, #248 DJNZ R7, $DJNZ R6, D2 DJNZ R5 D1 RET END, of course, also can use C language to write: #include #include // #define uint unsigned int contains the displacement function of #define uchar unsigned char uchar temp I; / / data type unsigned char 8 void delay (uint); void (main) {temp=0xfe; P1=temp; while (1) {fo R (i=0; i<8; i++) {temp=_cror_ (temp, 1); / / the right one delay (800); / / set the delay time P1=temp;} for (i=0; i<8; i++) {temp=_crol_ (temp, 1); / / left a delay (800); / / set the delay time P1=temp;}}} void (delay uint z) uint y {/ / delay procedures; (for; z>0; z--) for (y=248; y>0; y--;})

Share to: