I'm writing assembly code for the ATMEGA328P (arduino uno). i have a example from a book.
'Adjust the previous assignment so that the LED stays on even when you release the button. The LED must remain lit until the other button is pressed'
the previous assignment was:
'Create a program that lights an LED when a button is pressed. When button 0 is pressed, LED 0 must light up. When button 1 is pressed, LED 1 must light up.'
for this i have write some code( maybe not the best, but it works )
.include "m328Pdef.inc"
.def temp=r16
.def temp1=r18
.cseg
.org 0x0000
init:
ldi temp, 0xff
ldi temp1, 0x00
out DDRD, temp
out DDRB,temp1
out PORTB,temp1
loop:
in temp,PINB
out PORTD, temp
rjmp loop
so my question is how can i do the second assignment?
What I have tried:
i have tried to add this:
delay:
ldi temp, 0xFF
delay_loop_1:
dec temp
cpi temp, 0x00
jmp delay_loop_1
ret