This educational guide teaches you how to control a NEMA17 motor using only Assembly language on an Arduino UNO with the CNC Shield v3.0 — all without Arduino IDE or any libraries.
Unlike typical tutorials, we go straight to the heart of the ATmega328P microcontroller. No abstractions, just real registers and bits — just like how the datasheet shows. This method helps you truly understand how microcontrollers work at the lowest level.
Many beginners get confused by multiple names for the same pin:
Register 4, Bit 0
Register 9, Bit 2
We ignore symbolic names and use only numeric registers and bits as described in the ATmega328 datasheet.
Paste the following code into costycnc.github.io/avr-compiler-js, compile, and upload to your Arduino UNO:
.org 0
rjmp init
.org 0x60
init:
sbi 4,0 ; Enable driver (Register 4, Bit 0)
ldi r18,10 ; Load delay loop counter
call wait
sbi 9,2 ; Step pulse X motor (Register 9, Bit 2)
rjmp init
wait:
inc r17
brne wait
dec r18
brne wait
ret
Register 4, Bit 0
Register 9, Bit 2
to turn the motorThis method teaches students how to interact directly with hardware — no IDEs, no libraries, no abstractions. Just pure control using the ATmega328's datasheet and logic.
🔧 This is real engineering — and you can learn it now.