A bare-metal programming demonstration for the Arduino Uno (ATmega328P) to blink the onboard LED using direct register-level C programming. This project uses only AVR-GCC and AVRDude, with no Arduino libraries.
- Toggles the onboard LED (pin 13 / PB5) every 500ms.
- Utilizes direct AVR register manipulation for maximum efficiency.
- Simple build and flash process using a
Makefile. - Compatible with a VS Code + PlatformIO workflow.
- Version-controlled with Git & GitHub.
- Microcontroller: ATmega328P (on an Arduino Uno board)
- Onboard LED: Connected to Pin 13 (Port B, Pin 5)
- Connection: Standard USB cable
- Linux ( Ubuntu).
- Visual Studio Code (or any text editor)
- AVR Toolchain:
gcc-avr,avr-libc,avrdude makeutility- Git for version control
To install the required tools on a Debian/Ubuntu system:
sudo apt update
sudo apt install gcc-avr avr-libc avrdudearduino_baremetal/
├── blink.c # Main C source code for the blinking logic
├── Makefile # Build and flash automation script
├── .gitignore # Optional: Specifies files for Git to ignore
└── README.md # This documentation file
git clone https://github.com/Sreyz03/arduino_baremetal.git
cd arduino_baremetalCompile the source code to generate the executable .hex file.
make allThis command compiles blink.c → blink.o → blink.elf → blink.hex.
First, connect your Arduino and identify its serial port:
ls /dev/ttyACM*Update the PORT variable in the Makefile if it's different from /dev/ttyACM0.
Then, upload the compiled code to the Arduino:
make flashThe onboard LED should now be blinking!
To remove all generated files (.o, .elf, .hex):
make clean| Target | Description |
|---|---|
all |
Compiles the C code and generates the .hex file. |
flash |
Uploads the generated .hex file to the Arduino. |
clean |
Removes all compiled object and hex files. |
This project is licensed under the MIT License.