DIY Program Loader for ATmega and ATtiny ICs with Arduino Nano

Shivam Rajput
3 min readFeb 7, 2024

Have you ever wondered if you really need all the components that come with an Arduino board when creating a project? Do you really need an entire Arduino board to bring your project to life? The answer is “No.” You can create your project using just a microcontroller IC and a few components, without the need for complex hardware or boards. In this blog, I’ll guide you on how to create a project without an Arduino board and how to upload your code to a microcontroller.

Understanding the Basics

Before we dive into the technical details, let’s understand the basics of what we’re trying to achieve. Microcontrollers like the ATmega328P and ATtiny85 require a specific protocol and hardware setup to upload programs. This typically involves using a programmer device that interfaces with the microcontroller’s programming pins (MISO, MOSI, SCK, RESET) and provides the necessary voltage levels.

Components Needed

To build our project, we’ll need the following components:

  • ATmega328P Microcontroller: The heart of our project, which will run our program.
  • 16MHz Crystal Oscillator: Provides the clock signal for the microcontroller.
  • LED: For our LED blinking project, this will be our output device.
  • 220Ω Resistor: Limits the current flowing through the LED.
  • Two 22pF Ceramic Capacitors: Used with the crystal oscillator for clock stability.
  • Jumper Wires: For connecting the components together.

Additionally, we’ll need an Arduino Nano. You might be wondering why we need an Arduino Nano. We need it to upload the LED blink program to the microcontroller. We’ll use the Arduino Nano as a program loader. You can also use an Arduino Uno instead of an Arduino Nano.

Wiring Setup

Now that we have our components, let’s set up our wiring. Connect the components as follows:

ATmega328P to Components:

  • ATmega328P pin 7 (VCC) to 5V power supply
  • ATmega328P pin 8 (GND) to GND
  • ATmega328P pin 9 (XTAL1) to one leg of the 16MHz crystal oscillator
  • ATmega328P pin 10 (XTAL2) to the other leg of the 16MHz crystal oscillator
  • ATmega328P pin 19 (PB5) to the anode of the LED
  • ATmega328P pin 22 (GND) to one leg of the 220Ω resistor
  • The other leg of the 220Ω resistor to the cathode of the LED
  • 16MHz crystal oscillator each pin to one leg of each 22pF capacitor
  • The other leg of each 22pF capacitor to GND

Arduino Nano to ATmega328P:

  • Arduino Nano D13 (SCK) to ATmega328P pin 19 (PB5)
  • Arduino Nano D12 (MISO) to ATmega328P pin 18 (PB4)
  • Arduino Nano D11 (MOSI) to ATmega328P pin 17 (PB3)
  • Arduino Nano D10 (RESET) to ATmega328P pin 1 (RESET)

Optional LED Setup:

  • Connect an LED to Arduino Nano D9 with a resistor in series (e.g. 220Ω).
Connection Between Arduino and ATmega328P

Upload LED Blink program

We can use the example code for LED blinking provided by Arduino. Go to Files > Examples > Basics > Blink. After this, we need to make some configurations in the tools menu. Follow these steps:

  1. Select the Board as ATmega328. If you can’t find it in the board section, you’ll need to add the ATmega328 to the board section by configuring some settings.
  2. Open the File > Preferences menu item.
  3. Enter the following URL in Additional Boards Manager URLs: https://mcudude.github.io/MegaCoreX/package_MCUdude_MegaCoreX_index.json
  4. Separate the URLs using a comma (,) if you have more than one URL.
  5. Open the Tools > Board > Boards Manager… menu item.
  6. Wait for the platform indexes to finish downloading.
  7. Scroll down until you see the MegaCoreX entry and click on it.
  8. Click Install.
  9. After installation is complete, close the Boards Manager window.

Now, you’ll be able to select the board as ATmega328. Select Programmer as Arduino as ISP. Click on Burn Bootloader inside the tools menu. After that, go to Sketch and click on Upload using programmer. Once done, your project is ready. You can power the microcontroller externally with a 5V power supply, and it will work fine.

Conclusion

Congratulations! You’ve successfully built a program loader using an Arduino Nano to upload programs to ATmega and ATtiny microcontrollers. With this setup, you can now easily program these microcontrollers for your projects, opening up a world of possibilities for your creations. Happy hacking!

My Program loader

--

--