An open API service indexing awesome lists of open source software.

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 ๐Ÿ”ฅ

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)**. ๐Ÿ’ก