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

Yogesh Modi · November 12, 2018 at 3:10 am

How can i take this course?

    Crazy Engineer · November 12, 2018 at 8:21 am

    Hi Yogesh, Thanks a lot to check this course. I am currently writing the Tutorial and it is in progress. It will take a couple of Months to complete. This Course is completely Industry Specific. I am writing and hosting each topic one after another. So You can come back to the page each week and see a new topic and follow the sequence. Till then you can explore other free websites for tutorials. I will let you know when I finish the write-up.

      photon · April 6, 2019 at 5:58 pm

      Ummm. How do I ACTUALLY view the course??? There’s only a few things open. Are you still working on this, or is this it?

      Thanks for having atleast something. Its been really hard to find good tutorials teaching this exact topic!

        Crazy Engineer · April 16, 2019 at 8:15 pm

        Hi, Thanks for Appreciating. I am currently working on this. I will be Updating the rest of the topics. Till then Happy Making and Programming.

          Dandi · December 21, 2019 at 2:12 pm

          Hey, any updates? I’d love to have see more content by you. the tutorials so far are very professional and instructive. Kudos

          Crazy Engineer · December 31, 2019 at 7:35 pm

          Thanks, Dandi. I am trying my best to have time to write the full tutorial.

Njoku Okechukwu Valentine · December 30, 2018 at 10:15 am

Good day Sir.
What a good work you are doing! Keep it up. But how can linux (mint 19) try out this program codes and stuff.
I have browsed and there seems not to be Atmel Studio for linux users.
Thanks in advance

MANIKANTAN K V · March 26, 2020 at 4:49 pm

Im very much intrested on the content of the tutorial,how can i access it .still some contents are not available. is it complete soon?

    Crazy Engineer · March 31, 2020 at 10:02 pm

    I am under progress to add more content. Please explore the web meantime.

PETER · May 23, 2020 at 8:35 pm

HOW CAN I TAKE THIS COURSE PLEASE

George E Cole · January 29, 2021 at 1:18 am

Ditto Peter. I’d be interested in having access to more of the course content. I stumbled over your taster article which detailed some of the concepts of register/port/pin manipulation I had gleened from (various) other resources. The contents of your trutorial would seem to put together a lot of what I want to learn. I’ve ditched Arduino (using it as a bootstrap loader) for naked ATMega328Ps – as I’m as interested in the glue electronics and pcb assembly as software. Link Njoku, I’m no Windoze fan, so am using Visual Studio Code / Platformio (on Mac – which looks like Linux 😉 ) and is a pretty nice environment. I’m a retired and rusty embedded systems engineer revisiting my past. How things have changed since the 80’s 🙂

    Crazy Engineer · February 6, 2021 at 11:32 pm

    Thank you, George, for visiting my tutorial. Thank you for sharing your experience and views. I am working hard for delivering more tutorials. Stay Tuned.

rene caillet · February 2, 2021 at 5:10 pm

Bonjour,
Ce que vous avez fait jusqu’à présent est super et j’apprends beaucoup. Vivement la suite, je ne trouve pas de meilleurs tutoriel que le votre.
Encore merci pour le temps consacré aux autres.
René

    Crazy Engineer · February 6, 2021 at 11:35 pm

    Dear Rene, Thank You for visiting my page and finding my tutorial interesting and helpful. I am working hard to deliver more tutorials, Stay Tuned.

    Cher René, Merci d’avoir visité ma page et d’avoir trouvé mon tutoriel intéressant et utile. Je travaille dur pour fournir plus de tutoriels, Restez à l’écoute.

Chirag · April 7, 2021 at 4:29 pm

Is this course open source or any fees for this course?

    Crazy Engineer · April 14, 2021 at 3:26 pm

    Hi Chirag, This course is completely free and open. Please learn from this and share it with your friends.

Sangaran D K · September 2, 2021 at 8:56 am

When your full course is will be available? Kindly answer me.

    Crazy Engineer · September 2, 2021 at 9:40 pm

    Some Part is Available for Access, Thanks For Choosing

uttam · September 15, 2021 at 6:13 pm

How can i take this course?

Dhruv · September 7, 2022 at 4:06 pm

Please make it accessible as soon as possible…course looks interesting

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.