This repository contains two versions of a basic project that blinks an LED connected to pin 8 and sends "Hello, World!" over the serial port every second:
- Arduino IDE version: Uses the Arduino framework and libraries for easy development.
- Embedded C version: Written in pure C, using AVR registers and timers directly for accurate timing and serial communication.
- Arduino board
- LED and 220Ω resistor
- 2 Jumper wires
- Breadboard
- Path:
arduino/hello_world/hello_world.ino
- Description: This is the original Arduino IDE project. It blinks an LED connected to pin 8 and sends "Hello, World!" over the serial port every second using Arduino libraries.
- Path:
src/
- Description: This version uses AVR libraries and timers in pure C for the same functionality. No Arduino-specific libraries are used.
src/main.c
: Main logic file.src/usart/usart.c
andusart.h
: Handles serial communication using USART.src/timer/timer.c
andtimer.h
: Handles Timer1 for LED blinking.src/delay/delay.c
anddelay.h
: Provides accurate delay using Timer0.
- Connect the LED and resistor in series between pin 8 and ground.
- Open the
arduino/sketch/hello_world.ino
file in the Arduino IDE. - Select the correct board and port from the Tools menu.
- Upload the code to your Arduino board.
- Open the Serial Monitor at 9600 baud to see the "Hello, World!" message.
- GNU AVR Toolchain: Make sure
avr-gcc
,avr-libc
, andavrdude
are installed. - Make: For building the project using a
Makefile
.
-
Connect the LED and resistor in series between pin 8 and ground.
-
Clone or download the repository and navigate to the root directory.
-
Modify the Makefile: Open the
Makefile
and update theAVRDUDE_PORT
line to use the correct port for your system.- For macOS, the port may look like
/dev/cu.usbserial-xxxx
. - For Linux, it could be
/dev/ttyUSB0
or/dev/ttyACM0
. - For Windows, it might be
COMx
(wherex
is the COM port number).
Example:
AVRDUDE_PORT = /dev/ttyUSB0 # Update this to match your system
- For macOS, the port may look like
-
Run the following commands to compile and upload the program:
make clean # Clean any previous build files make # Compile the project and generate the .hex file make upload # Upload the compiled .hex file to your Arduino board
-
Open your serial terminal or the Arduino IDE Serial Monitor at 9600 baud to see the "Hello, World!" message being printed every second.