Programming the cheap Atmel Attiny13a using Arduino - The easy way

Intro

Attiny13/Attiny13a is one of the smallest and cheapest MCUs from Atmel (I got 10 pieces for 5 euros). You can easily build some basic sketches using the Arduino IDE without any hassle, but first, let’s look at the pinout diagram of this little guy.

Attiny13 Pinout

Attiny13a

Setting up Arduino with Attiny

Every Arduino UNO board has a “special ability” where it can be used as an ISP AVR programmer just by grounding the RESET PIN (using a 10μF capacitor). But before wiring things up, Arduino must be flashed first to “act” as a programmer just by uploading the ArduinoISP code to it.

Programming Attiny

The Attiny chip can be flashed just by connecting the Arduino pins 10, 11, 12, 13 with the Attiny13a PINS 1, 5, 6, 7. Don’t forget to provide enough power, supplying 5 volts to PIN 8, and of course, connect PIN 4 to any Arduino ground PIN.

I couldn’t find the DIP8 version in my local electronics store, so I grabbed this SMD version and soldered the pins with some wires and uploaded the following code (after burning the bootloader); everything works fine.

BONUS TTL Connection

Attiny13 has a 1KB flash size which makes it incompatible with the Arduino serial library because of its size. I found a small serial library on Google that can make TTL possible using only 62 bytes of flash. Steps: Steps:

  1. Grab the library from https://github.com/nerdralph/picoUART
  2. Based on the project’s example:
#include <picoUART.h>
#include <pu_print.h>

void setup() {}

void loop()
{
    uint8_t c;
    prints_P(PSTR("\r\npicoUART echo "));
    c = purx();
    prints_P(PSTR(" got: "));
    putx(c);
}

Sources https://create.arduino.cc/projecthub/taunoerik/programming-attiny13-with-arduino-uno-07beba

Follow me on Twitter! It's free!