0% found this document useful (0 votes)
31 views

Assignment 04

The program codes 16 LEDs to glow one by one for one second each in a clockwise and anticlockwise direction. It initializes ports and counters, then calls subroutines to glow the LEDs forward or backward while also generating a one second delay between each LED. This pattern is repeated for both the first and last 8 LEDs.

Uploaded by

Neha Rajput
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

Assignment 04

The program codes 16 LEDs to glow one by one for one second each in a clockwise and anticlockwise direction. It initializes ports and counters, then calls subroutines to glow the LEDs forward or backward while also generating a one second delay between each LED. This pattern is repeated for both the first and last 8 LEDs.

Uploaded by

Neha Rajput
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

ASSIGNMENT -04

QUESTION:

Write a program to glow 16 LEDs one by one of one second in clockwise and then in
anticlockwise direction.

MACHINE PROGRAM CODE


CYCLE
1 MOV TMOD, #10H ; Timer 1 Mode 1, XTAL Frequency = 22 MHz

1 MOV P0, #0FFH ; Configuring P0 as input

1 MOV P2, #0FFH

1 RE: MOV A, P0
1 MOV R2, #9 ; Counter for 8 LED's
1 MOV R1, #80H ; For glowing one LED at a time
1 SETB C

1 JUMP1: MOV R0, #28 ; For generating a delay of 1 sec


2 BACK1: ACALL DELAY
2 DJNZ R0, BACK1
2 ACALL FWD1 ; Clockwise glowing of 8 first LEDs
2 DJNZ R2, JUMP1

1 MOV A, P2
1 MOV R1, #80H
1 MOV R2, #9
1 JUMP2: MOV R0, #28
2 BACK2: ACALL DELAY
2 DJNZ R0, BACK2
2 ACALL FWD2 ; Clockwise glowing of last 8 LEDs
2 DJNZ R2, JUMP2

1 MOV R1, #01H


1 MOV R2, #9
1 JUMP3: MOV R0, #28
2 BACK3: ACALL DELAY
2 DJNZ R0, BACK3
2 ACALL BWD1 ; Anti-Clockwise glowing of last 8 LEDs
2 DJNZ R2, JUMP3

1 MOV A, P0
1 MOV R1, #01H
1 MOV R2, #9
1 JUMP4: MOV R0, #28
2 BACK4: ACALL DELAY
2 DJNZ R0, BACK4
2 ACALL BWD2 ; Anti-Clockwise glowing of first 8 LEDs
2 DJNZ R2, JUMP4
2 SJMP RE

1 BWD1: XRL A, R1 ;Glowing one LED at a time


1 MOV P2, A
1 MOV R3, A
1 MOV A, R1
1 RLC A
1 MOV R1, A
1 MOV A, R3
2 RET

1 BWD2: XRL A, R1 ; Glowing one LED at a time


1 MOV P0, A
1 MOV R3, A
1 MOV A, R1
1 RLC A
1 MOV R1, A
1 MOV A, R3
2 RET

1 FWD1: XRL A, R1 ; Glowing one LED at a time


1 MOV P0, A
1 MOV R3, A
1 MOV A, R1
1 RRC A
1 MOV R1, A
1 MOV A, R3
2 RET

1 FWD2: XRL A, R1 ; Glowing one LED at a time


1 MOV P2, A
1 MOV R3, A
1 MOV A, R1
1 RRC A
1 MOV R1, A
1 MOV A, R3
2 RET

1 DELAY: MOV TL1, #00H ; Generating a delay of 1 sec


1 MOV TH1, #00H
1 SETB TR1
2 AGAIN: JNB TF1, AGAIN
1 CLR TF1
1 CLR TR1
2 RET

Total Machine Cycles: 98


SIMULATION USING PROTEUS

You might also like