Learn, Implement and Share

Embedded C on the Arduino Uno R3

Learn how the ATmega328P works beneath the familiar Arduino board. This course takes you from the first register-level C program through GPIO, timers, communication interfaces, analogue input, memory and complete sensor and module examples.

Start Learning: Open the ATmega328P Course

Course overview for Embedded C on the Arduino Uno R3

Who Is This Course For?

The course is for students, hobbyists and working engineers who know basic C and want to understand how a microcontroller interacts with hardware. You do not need previous experience with embedded systems. Lessons introduce the electronics and microcontroller ideas as they are needed.

The examples target an Arduino Uno R3 with an ATmega328P running at 16 MHz. Other Arduino boards may use a different microcontroller and are not interchangeable with these examples.

How The Course Works

We begin with direct ATmega328P register programming in C, so you can see how the processor configures and uses its peripherals. Later lessons introduce the course HAL and show how to organise reusable drivers. Each maintained lab also includes an Arduino IDE sketch for comparison; the lessons explain what the Arduino core handles and which peripherals it may already use.

You can build the C projects with MPLAB for VS Code and XC8, or use the supplied command-line build tool with AVR GCC. Open the comparison sketches in Arduino IDE 2.x. Each practical lesson links its source, describes the circuit and wiring, walks through the important code, and explains how to build, upload and observe the result.

What You Will Need

  • An Arduino Uno R3 board with the ATmega328P and a USB data cable.
  • A computer running Windows for the setup examples, with VS Code, the MPLAB extension and XC8 installed as described in the setup lessons.
  • A breadboard, jumper wires, an LED and a suitable series resistor, and a push button for the first exercises.
  • A multimeter is useful. Additional components are listed in the relevant module lessons.

The course starts with small, low-voltage circuits. Follow each wiring diagram, use a current-limiting resistor for LEDs, and use a suitable driver and external supply for motors, relays and other loads.

What You Will Learn

  • How an embedded system differs from a general-purpose computer, and how to plan and maintain firmware.
  • How the AVR CPU executes instructions and uses registers, Flash, SRAM, EEPROM, clocks and interrupts.
  • How to configure GPIO and connect buttons, displays, keypads, shift registers and sensors.
  • How to use timers, counters, PWM and input capture for timing, motor control, sound, servos and encoders.
  • How SPI, USART and TWI/I²C transactions work, from peripheral registers to reusable drivers.
  • How to sample analogue signals with the ADC and use the analogue comparator.
  • How to work with EEPROM and Flash, and how to connect common sensors, displays, radios, storage devices and actuators.
  • How to use state machines, ring buffers, sleep modes and the watchdog in small microcontroller projects.

Course Lessons

Use the linked lessons below in order, or open the course and choose a topic from its navigation and search.

Introduction

Setup And Installation

Embedded Systems

AVR Architecture

GPIO

Timers And PWM

SPI

USART

TWI And I²C

Analogue Comparator

ADC

Nonvolatile Memory

Sensors, Displays And Modules

Advanced Topics

Embedded C Foundations

Code, Experiments And Reference Material

The course pages link to the firmware for each example. You can browse or clone the repositories directly:

To clone the course source and its linked repositories:

git clone --recurse-submodules https://github.com/arnabdasbwn/atmega328p-tutorial.git

Start Learning

Begin with Course Introduction And Learning Path, continue with Installing VS Code, MPLAB And XC8, and build Your First Register-Level Blink.

Open the full ATmega328P course

29 Comments

Rahul Barnwal · December 15, 2022 at 3:45 pm

Please Update the I2C part as soon as possible.

Ben · March 5, 2023 at 12:43 pm

Sir, it’s 2023, is the course still actively updated? I’m amazed and really intrested in your course structure, and glad it is free. However even if it’s not free i’d be happy to pay for full access to the finished course contents. If there’s a way to support (donate) you to finish the contents i’d be happy to help sir. Thanks

    Crazy Engineer · April 5, 2023 at 11:03 am

    Ben, I am short of time and thus slow in adding new content to the course, feel free to explore the internet.

Amir · December 8, 2023 at 2:49 am

New for learning

Abdullah · May 25, 2024 at 3:25 pm

Hey man, just wanted to say keep it up and take your time, this seems like an amazing course and its awesome that its free!

Also bit of a common and overused question, but I have experience with Python, a little bit of C/C++ (made a crappy and very basic text editor in C and done some projects for Arduino) but would like to ask what would be a good way to get into assembly (thought learning AVR assembly would be a good idea since arduino is such an open microcontroller) or what could be some projects I can make with AVR asm.Thanks!

Patrick Akugizibwe · August 7, 2024 at 4:35 pm

Am Interested in the course

K.Seetharaman · April 16, 2025 at 4:56 pm

sir
i am also interested to learn what is the timing and course fees,i am working in chemical industry E&I Dept

Crazy Engineer · November 9, 2026 at 10:16 pm

Tutorial is Updated. Enjoy Learning.

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.