https://github.com/bavinnk/arduino-led-sequencer-inline-assembly-version-
An Arduino 6-LED sequencer, rewritten from C++ to run on inline AVR assembly. It's a dive into low-level microcontroller programming, proving that assembly still has its place, even for a "simple" blink.
https://github.com/bavinnk/arduino-led-sequencer-inline-assembly-version-
arduino-uno assembly-language-programming cpp diagram inline-assembly simulation
Last synced: 12 months ago
JSON representation
An Arduino 6-LED sequencer, rewritten from C++ to run on inline AVR assembly. It's a dive into low-level microcontroller programming, proving that assembly still has its place, even for a "simple" blink.
- Host: GitHub
- URL: https://github.com/bavinnk/arduino-led-sequencer-inline-assembly-version-
- Owner: BavinnK
- License: mit
- Created: 2025-05-23T18:55:37.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-23T19:05:13.000Z (about 1 year ago)
- Last Synced: 2025-06-07T11:09:10.273Z (about 1 year ago)
- Topics: arduino-uno, assembly-language-programming, cpp, diagram, inline-assembly, simulation
- Language: C++
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Arduino LED Sequencer (Inline Assembly Version)
This project demonstrates controlling a sequence of 6 LEDs on an Arduino UNO, but with a twist: the core LED control logic is implemented using **inline AVR assembly language** within the Arduino C++ environment.
This is an evolution of a previous project that accomplished the same LED sequencing task purely in C++. About a month or two ago, it was all `digitalWrite()`. Now? Now we're talking directly to the metal!
## Diagram


## Features
* Sequentially lights up 6 LEDs.
* Utilizes inline AVR assembly for the primary LED control logic.
* Demonstrates bit-shifting (`lsl`) in assembly to select which LED to illuminate.
* Directly manipulates hardware I/O ports (`PORTB`) from assembly.
* Shows how to pass data (the `counter` variable) from C++ to assembly.
* Properly preserves and restores register states (`push`/`pop`) used by the assembly block.
## Hardware Requirements
* Arduino UNO (or compatible)
* 6 x LEDs (any color)
* 6 x Current-limiting resistors (e.g., 220Ω - 330Ω, appropriate for your LEDs and 5V)
* Breadboard
* Jumper wires
## Wiring
As seen in the image, the LEDs are connected to Arduino digital pins 8 through 13. These pins correspond to PORTB (PB0 to PB5) on the ATmega328P microcontroller.
1. **LED 1 (controlled by PB0/D8):** Connect Anode to Digital Pin 8 via a resistor. Cathode to GND.
2. **LED 2 (controlled by PB1/D9):** Connect Anode to Digital Pin 9 via a resistor. Cathode to GND.
3. **LED 3 (controlled by PB2/D10):** Connect Anode to Digital Pin 10 via a resistor. Cathode to GND.
4. **LED 4 (controlled by PB3/D11):** Connect Anode to Digital Pin 11 via a resistor. Cathode to GND.
5. **LED 5 (controlled by PB4/D12):** Connect Anode to Digital Pin 12 via a resistor. Cathode to GND.
6. **LED 6 (controlled by PB5/D13):** Connect Anode to Digital Pin 13 via a resistor. Cathode to GND.
*Ensure all LED cathodes share a common ground with the Arduino.*
## Software Requirements
* Arduino IDE
* The AVR-GCC toolchain (this is included with the Arduino IDE)