https://github.com/amalchandru/blinking-leds
.ino -> .c ๐ฅ
https://github.com/amalchandru/blinking-leds
arduino atmega328p avr avr-gcc c
Last synced: 4 months ago
JSON representation
.ino -> .c ๐ฅ
- Host: GitHub
- URL: https://github.com/amalchandru/blinking-leds
- Owner: AmalChandru
- License: gpl-3.0
- Created: 2025-02-15T11:41:01.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2025-02-15T12:31:24.000Z (4 months ago)
- Last Synced: 2025-03-04T04:15:54.530Z (4 months ago)
- Topics: arduino, atmega328p, avr, avr-gcc, c
- Language: C++
- Homepage:
- Size: 1.38 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ๐ .ino -> .c
## ๐ Overview
This repository walks you through the process of transforming an Arduino Blink sketch into optimized AVR C code. The journey involves replacing high-level Arduino functions with direct hardware manipulation.## ๐ง Optimization Stages
- โก **Replacing `digitalWrite()`**: Transition from `digitalWrite()` to direct port manipulation for faster control.
- ๐ **Replacing `pinMode()`**: Use direct register manipulation (`DDRx`) to set pin direction.
- โณ **Replacing `delay()`**: Implement a custom for-loop to replace `delay()` and reduce overhead.
- ๐ฏ **Final AVR C Code**: Complete conversion to low-level AVR C code, optimizing every aspect.## ๐ Commit History
- ๐ต **[98918db](https://github.com/AmalChandru/Blinking-LEDs/commit/98918db6975ce1adb744acdb69660f5daf91587f)**: Replaced `digitalWrite()` with direct port manipulation (`PORTB`).
- ๐ต **[1028d2c](https://github.com/AmalChandru/Blinking-LEDs/commit/1028d2c90d6b540713abbcbbe9ffc6af6ca94e0b)**: Replaced `pinMode()` with direct register manipulation (`DDRB`).
- ๐ต **[fede5a4](https://github.com/AmalChandru/Blinking-LEDs/commit/fede5a437513da22d48f762a576efe34cedac99e)**: Replaced `delay()` with a custom for-loop for time delay.
- ๐ต **[4b1de20](https://github.com/AmalChandru/Blinking-LEDs/commit/4b1de204b7b84c6b345201b29f361e136b8d8444)**: Final AVR C code with all optimizations.
- ๐ต **[4471702](https://github.com/AmalChandru/Blinking-LEDs/commit/44717023661095e0ce6e657a475755ed8c092f0f)**: A Makefile to compile and flash.## ๐ How to Run
### ๐ฆ Install Tools
Install the AVR toolchain (`avr-libc`, `binutils-avr`, `gcc-avr`, `avrdude`):```sh
sudo apt install avr-libc avrdude binutils-avr gcc-avr
```### ๐ Clone the Repository
```sh
git clone https://github.com/AmalChandru/Blinking-LEDs.git
cd Blinking-LEDs
```### ๐ Compile
Use `make` to compile the final code:```sh
make
```### ๐ฅ Flash
Upload the `.hex` file with `avrdude`:```sh
make upload
```
๐ Enjoy the blinking LED!### ๐งน Clean
Clean object and binary files:
```sh
make clean
```## ๐ Source Material
This repository is the source material for the talk **["Blinking LEDs: For the Brave and the Curious"](https://github.com/AmalChandru/Blinking-LEDs/blob/main/Blinking%20LEDs%3A%20For%20the%20Brave%20and%20Curious.pdf)**. ๐ก