Experiment on using single chip microcomputer to control the lighting sequence of small lights in the chassis
[Copy link]
org 0000h /* Set the starting address of the program segment */ ljmp main org 000bh ljmp ctc org 0030h main: mov tmod,#01h /* set address pointer */ mov th0,#3ch mov tl0,#0b0h mov r2,#0ah setb ea /*ea set to 1*/ setb et0 /* et0 set to 1*/ setb tr0 /* tr0 set to 1*/ mov a,#01h /* assign value to accumulator a */ sjmp $ /* step */ ctc: mov th0,#3ch /* initialize t0 */ mov tl0,#0b0h djnz r2,next /*r2=0?, If not equal, transfer to next*/ mov p1,a /* send the number in a to p1 */ mov r2,#0ah /* assign value to r2 */ rl a /* Shift the value in a to the left by one position */ next: reti /* Interrupt the subroutine and return to the main program */ end /* End of program */ start | ↓ | Set the initial value of the address pointer | ↓ | Modify the address pointer | ↓
↓ Y | The number in a is sent to p1 | ↓ | R2 assignment | ↓ | Numeric shift |
| END | flow chart:
Experimental steps: 1. Connect the wires on the microcontroller; 2. Input the program into the computer; 3. Turn on the power of the microcontroller and the display will show C_ ; 4. Run the program; 5. Observe the process of the small lamp lighting up; 6. Change the program to change the order in which the small lights light up; 7. Turn off the power and put the experimental device back to its original position. Running result: The small lights on the chassis light up in a left-right cycle. This is a program we use when we practice learning. I tried it and found it very interesting. I will show it to you. If you have the opportunity, you can try it.
|