Wednesday, 23 November 2016

Shifting LEDs Pattern with AT89S52 in Assembly _ Best Embedded Tutorial

Shifting Effect can be formed on LEDs by just turning each LED individually with remaining Off for the meanwhile.
Here is the simple code for forming such shifting pattern.



MOV A, #10000000B
     AGAIN:RR A
MOV P2, A
ACALL DELAY
SJMP AGAIN
DELAY:                                        //Program for delay
 MOV  R1, #10
 MOV  R2, #10
 MOV  R3, #2
LOOP1: DJNZ R3, LOOP1
               DJNZ R2, Y2
               DJNZ R1, Y3
RET
END

/*You may program in simple way if you find the first one messy
AGAIN:
MOV P2,#10000000B
ACALL DELAY
MOV P2,#01000000B
ACALL DELAY
MOV P2,#00100000B
ACALL DELAY
MOV P2,#00010000B
ACALL DELAY
MOV P2,#00001000B
ACALL DELAY
MOV P2,#00000100B
ACALL DELAY
MOV P2,#00000010B
ACALL DELAY
MOV P2,#00000001B
ACALL DELAY
SJMP AGAIN

DELAY:                                        //Program for delay
 MOV  R1, #10
 MOV  R2, #10
 MOV  R3, #2
LOOP1: DJNZ R3, LOOP1
               DJNZ R2, Y2
               DJNZ R1, Y3
RET
END
                                        Both programs will have same output
*/

No comments:

Post a Comment