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

Assignment - 03: Write A Program To Glow 8 Leds One by One of One Second in Clockwise and Then in Anticlockwise Direction

The document describes a program to glow 8 LEDs in clockwise and anticlockwise directions using a microcontroller. The program uses timers and counters to generate a 1 second delay between glowing each LED. Subroutines are used to glow the LEDs in the forward and backward directions by shifting a bit pattern to select each LED in turn.

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)
30 views

Assignment - 03: Write A Program To Glow 8 Leds One by One of One Second in Clockwise and Then in Anticlockwise Direction

The document describes a program to glow 8 LEDs in clockwise and anticlockwise directions using a microcontroller. The program uses timers and counters to generate a 1 second delay between glowing each LED. Subroutines are used to glow the LEDs in the forward and backward directions by shifting a bit pattern to select each LED in turn.

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/ 2

ASSIGNMENT -03

QUESTION:

Write a program to glow 8 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 A, P0
1 MOV R2, #9 ; Counter for 8 LED's
1 MOV R1, #80H
1 MOV R3, #00H
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 FWD ;Clockwise glowing of 8 LEDs
2 DJNZ R2, JUMP1

1 MOV R1, #01H


1 MOV R2, #9
1 JUMP2: MOV R0,#28
2 BACK2: ACALL DELAY
2 DJNZ R0, BACK2
2 ACALL BACK ;Anti-Clockwise glowing of 8 LEDs
2 DJNZ R2, JUMP2

1 FWD: 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 BACK: 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 DELAY: MOV TL1, #00H


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

Total machine cycles: 54

SIMULATION USING PROTEUS

You might also like