Last active
April 7, 2017 09:43
-
-
Save TheRealMentor/4f43b1c97b8f79cf82bd1740f5b438f8 to your computer and use it in GitHub Desktop.
Blinking of LED's sequentially in circular fashion. Follow this project on : https://the-real-mentor.blogspot.in/2017/04/arduino-led-ring.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;======================== | |
;File: circle.asm | |
;Author: TheRealMentor | |
;Created on: 07/04/17 | |
;======================== | |
;======================================== | |
;INCLUDING HEADER FILE FOR Chip ATmega328P | |
;======================================== | |
.include "/usr/share/avra/m328Pdef.inc" | |
;======================================== | |
;Initializing the pins | |
;======================================== | |
main: | |
ldi r16, 0b00001111 ;Pins of Port B : 8,9,10,11 | |
out DDRB, r16 | |
ldi r20, 0b11111100 ;Pins of Port D : 2,3,4,5,6,7 | |
out DDRD, r20 | |
;======================================== | |
;Main function | |
;======================================== | |
mainloop: | |
in r28,PINC ;Taking input from Port C and storing it in R28 | |
cpi r28,0x00 ;Comparing value of R28 with 0x00 | |
breq mainloop ;If equal, then mainloop will again run | |
call circle ;If not equal, then circle function is called | |
rjmp mainloop ;Running mainloop infinite times | |
circle: | |
ldi r16, 0b00000010 ;Making 1st LED high | |
out PORTB, r16 | |
call wait | |
ldi r16, 0b00000000 ;Making it low | |
out PORTB, r16 | |
ldi r19, 0b00000001 ;Making 2nd LED high | |
out PORTB, r19 | |
call wait | |
ldi r19, 0b00000000 ;Making it low | |
out PORTB, r19 | |
ldi r26, 0b00000100 ;Making 3rd LED high | |
out PORTB, r26 | |
call wait | |
ldi r26, 0b00000000 ;Making it low | |
out PORTB, r26 | |
ldi r27, 0b00001000 ;Making 4th LED high | |
out PORTB, r27 | |
call wait | |
ldi r27, 0b00000000 ;Making it low | |
out PORTB, r27 | |
ldi r20, 0b00000100 ;Making 5th LED high | |
out PORTD, r20 | |
call wait | |
ldi r20, 0b00000000 ;Making it low | |
out PORTD, r20 | |
ldi r21, 0b00001000 ;Making 6th LED high | |
out PORTD, r21 | |
call wait | |
ldi r21, 0b00000000 ;Making it low | |
out PORTD, r21 | |
ldi r22, 0b00010000 ;Making 7th LED high | |
out PORTD, r22 | |
call wait | |
ldi r22, 0b00000000 ;Making it low | |
out PORTD, r22 | |
ldi r23, 0b00100000 ;Making 8th LED high | |
out PORTD, r23 | |
call wait | |
ldi r23, 0b00000000 ;Making it low | |
out PORTD, r23 | |
ldi r24, 0b01000000 ;Making 9th LED high | |
out PORTD, r24 | |
call wait | |
ldi r24, 0b00000000 ;Making it low | |
out PORTD, r24 | |
ldi r25, 0b10000000 ;Making 10th LED high | |
out PORTD, r25 | |
call wait | |
ldi r25, 0b00000000 ;Making it low | |
out PORTD, r25 | |
;==================================== | |
; D E L A Y | |
;==================================== | |
wait: | |
ldi r16, 0x20 | |
ldi r17, 0x00 | |
ldi r18, 0x00 | |
w0: | |
dec r18 | |
brne w0 | |
dec r17 | |
brne w0 | |
dec r16 | |
brne w0 | |
ret | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment