user82016: I want to blink a led using assembly language and arduino
I want the circuit to have a normal state of 5 hz blinking frequency
Then use two push buttons to increase or decrease the blinking frequency
The up button will increment the blinking frequency by 5 hz step until the led seems to be continuously on
While the down button will decrement the blinking frequency by 5 hz step until the normal state again
Is this achievable ?
And if any one can point me where to start as this the first time i am using assembly language but i am familiar with arduino

user31668: Here is one example of how to blink an LED in assembly coding on an Arduino UNO. You can attempt to solve your challenge. If you are stuck, please post the code and the connections and I am sure, you will get help again.
The code is here
#define __SFR_OFFSET 0

#include "avr/io.h"

.global main

main:
  sbi   DDRB, 5     ; Set PB5 as output

blink:
  sbi   PINB, 5     ; Toggle PINB
  ldi   r25, hi8(1000)
  ldi   r24, lo8(1000)
  call  delay_ms
  jmp   blink

delay_ms:
  ; Delay about (r25:r24)*ms. Clobbers r30, and r31.
  ; One millisecond is about 16000 cycles at 16MHz.
  ; The inner loop takes 4 cycles, so we repeat it 3000 times
  ldi   r31, hi8(4000)
  ldi   r30, lo8(4000)
1:
  sbiw    r30, 1
  brne    1b
  sbiw    r24, 1
  brne    delay_ms
  ret

Link to the project: https://wokwi.com/arduino/projects/290348681199092237


82016: <p>I want to blink a led using assembly language and arduino
I want the circuit to have a normal state of 5 hz blinking frequency
Then use two push buttons to increase or decrease the blinking frequency
The up button will increment the blinking frequency by 5 hz step until the led seems to be continuously on
While the down button will decrement the blinking frequency by 5 hz step until the normal state again
Is this achievable ?
And if any one can point me where to start as this the first time i am using assembly language but i am familiar with arduino</p>
 31668: <p>Here is one example of how to blink an LED in assembly coding on an Arduino UNO. You can attempt to solve your challenge. If you are stuck, please post the code and the connections and I am sure, you will get help again.</p>
<p>The code is here</p>
<pre><code>#define __SFR_OFFSET 0

#include &quot;avr/io.h&quot;

.global main

main:
  sbi   DDRB, 5     ; Set PB5 as output

blink:
  sbi   PINB, 5     ; Toggle PINB
  ldi   r25, hi8(1000)
  ldi   r24, lo8(1000)
  call  delay_ms
  jmp   blink

delay_ms:
  ; Delay about (r25:r24)*ms. Clobbers r30, and r31.
  ; One millisecond is about 16000 cycles at 16MHz.
  ; The inner loop takes 4 cycles, so we repeat it 3000 times
  ldi   r31, hi8(4000)
  ldi   r30, lo8(4000)
1:
  sbiw    r30, 1
  brne    1b
  sbiw    r24, 1
  brne    delay_ms
  ret
</code></pre>
<p>Link to the project: <a href="https://wokwi.com/arduino/projects/290348681199092237" rel="nofollow noreferrer">https://wokwi.com/arduino/projects/290348681199092237</a>
<a href="https://i.stack.imgur.com/GQdKY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GQdKY.png" alt="enter image description here" /></a></p>
