Introduction: Updated Guide on How to Program an Attiny13a or 13 With the Arduino IDE

Picture of Updated Guide on How to Program an Attiny13a or 13 With the Arduino IDE

The ATtiny13 series chips are extremely cheap and useful chips for small projects that don't need a full Arduino, but due to very outdated tutorials and a lack of information, it took me the better part of a day to figure out how to program these with the Arduino IDE.

To fix this lack of information, in this Instructable, I will show you how to program your ATtiny13 or ATtiny13a with an up to date version of the Arduino IDE.

Step 1: The Hardware You Need

Picture of The Hardware You Need

Required Hardware

• Arduino (Uno is the easiest, but any Arduino will work)
• ATtiny13 or 13a
• Breadboard
• Jumper Wires



Troubleshooting Hardware (not necessarily required)

• 10uf electrolytic capacitor
• Any large electrolytic capacitor (mine is 1000uf, but any capacitance 100uf and above will work best)

Step 2: Setting Up the Hardware

Picture of Setting Up the Hardware

Connect the pins of the Arduino to the ATtiny as shown in the image or table below.

Important Note: Make sure to orient your ATtiny such that the indicator dot on your chip is in the bottom left corner as shown in the images (across from the 5v line). Orienting your ATtiny the opposite way can hurt the chip.

Arduino____________ATtiny13(a)

5v----------------------------Pin 8

GND------------------------Pin 4

Pin 13-----------------------Pin 7

Pin 12-----------------------Pin 6

Pin 11-----------------------Pin 5

Pin 10-----------------------Pin 1

Step 3: Setting Up the Arduino As ISP

Picture of Setting Up the Arduino As ISP

Navigate to Files-Examples-ArduinoISP and click on ArduinoISP. Upload this sketch to your Arduino. Now your Arduino is set up as a programmer for programming other chips.

Step 4: Downloading the Attiny13(a) Core Files

Picture of Downloading the Attiny13(a) Core Files

To program the ATtiny13 or 13a, you will need to install the core files. For this we will be using the core files created by sleepmanj, which I find to be the easiest to install and the best to use.

To install these files, open your Arduino IDE and navigate to the files drop-down menu, then select preferences. Paste this URL "https://raw.githubusercontent.com/sleemanj/optiboot/master/dists/package_gogo_diy_attiny_index.json" where it says "Additional Boards Manager URLs:". If you already have a URL here and want to add more, separate the URLs with a comma and a space.

Now navigate to tools-board and click on Boards Manager.... Now scroll down until you see DIY ATtiny and click the install button (it will default to the newest version).

Step 5: Burning the Bootloader to the Attiny

Picture of Burning the Bootloader to the Attiny

Go to Tools-Board and select ATtiny13. After selecting ATtiny13, navigate to Tools-Processor Version and select either ATtiny13 or ATtiny13a depending on your chip. Do not change any other settings until you know what they do, they can mess up what you are trying to accomplish. Finally, click the Burn Bootloader button at the bottom of the tools drop-down menu.

Important Note:You should make sure your programmer is set as "Arduino as ISP"

Step 6: Programming the Chip

Picture of Programming the Chip

You're at the homestretch! To make sure everything is working, let's upload the blink sketch to the ATtiny. Navigate to Files-Examples-Basics and select Blink.

There are a few changes we will need to make though. In the program, change every instance of "LED_BUILTIN" to "4" because our ATtiny doesn't have a built in LED. This "4" corresponds to pin 3 of the ATtiny (This can get confusing, you can reference what number in the IDE corresponds to what pin on the diagram in the "Troubleshooting" step). Now you can upload this code to your ATtiny through your Arduino by clicking the upload button.

To test to see if it worked, connect an LED (along with an appropriate resistor) between pin 3 on the ATtiny and ground as shown in the diagram and image above. The LED should be blinking on and off. If it is, congratulations! You now know how to program an ATtiny13 or 13a! You can now disconnect all wires except the 5v and ground.

If your LED isn't blinking, don't worry, proceed to the troubleshooting step to fix your problems.

Step 7: Troubleshooting

Picture of Troubleshooting

Something always goes wrong when working with new things, that's ok! Let's try to fix these issues. Try these in the order they show up.


• Double check all of your connections and your orientation of the ATtiny and LED.
• Re-upload the ArduinoISP sketch to your Arduino.
• Connect a 10uf electrolytic capacitor between ground and reset on your Arduino. Make sure to plug in the capacitor in the correct orientation, negative goes to ground.
• Connect any large capacitor between the 5v and ground on the breadboard, this will help smooth out any voltage spikes.
• Make sure enough power is getting to the Arduino that is programming the ATtiny, a 9 volt battery might not work.
• Switch out your Arduino with a different Arduino
• Make sure you're using an up to date IDE and up to date core files
• Click on tools and make sure the drop down menu looks the same as the menu shown in the "Burn the Bootloader" step. If something is different, change it and re-burn the bootloader.

Step 8: Great Job!

Congratulations on programming your ATtiny and thanks for reading my Instructable!

Comments

BallscrewBob (author)2017-11-01

Just been given some ATTINY 13A and already have a home made shield that works great for for 45's and 85's but I get the following and wonder if these is any way to sort this out ?

Using IDE 1.8.3 or above all give the same issue under win 7 X64 pro.

"

avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53

Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

Copyright (c) 2007-2014 Joerg Wunsch

System wide configuration file is "d:\Users\Bob\AppData\Local\Arduino15\packages\diy_attiny\hardware\avr\2017.10.29/avrdude.conf"

Using Port : COM20

Using Programmer : stk500v1

Overriding Baud Rate : 19200

AVR Part : ATtiny13

Chip Erase delay : 4000 us

PAGEL : P00

BS2 : P00

RESET disposition : dedicated

RETRY pulse : SCK

serial program mode : yes

parallel program mode : yes

Timeout : 200

StabDelay : 100

CmdexeDelay : 25

SyncLoops : 32

ByteDelay : 0

PollIndex : 3

PollValue : 0x53

Memory Detail :

Block Poll Page Polled

Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack

----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------

eeprom 65 5 4 0 no 64 4 0 4000 4000 0xff 0xff

flash 65 6 32 0 yes 1024 32 32 4500 4500 0xff 0xff

signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00

lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00

calibration 0 0 0 0 no 2 0 0 0 0 0x00 0x00

lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00

hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00

Programmer Type : STK500

Description : Atmel STK500 Version 1.x firmware

Hardware Version: 2

Firmware Version: 1.18

Topcard : Unknown

Vtarget : 0.0 V

Varef : 0.0 V

Oscillator : Off

SCK period : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x000000 (retrying)

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x000000 (retrying)

Error while burning bootloader.

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x000000

avrdude: Yikes! Invalid device signature.

Double check connections and try again, or use -F to override

this check.

ramoal (author)2017-09-08

Hi, when I clic on Burn Bootloader I've this message:

avrdude: failed to open parallel port "/dev/parport0"

Error while burning bootloader.

Please any helps?

THANKS IN ADVANCE.

Have you made sure the correct port is selected and your programmer is set as "Arduino as ISP"

Thanks a lot it works.

gilebea made it! (author)2017-09-26

Hello. Congrats. Please, why do I have to "Burn Bootloader"? Thank you. Regards.

PaulH433 (author)2017-09-12

Perfect! Works well for me. Now I need to find a project for the 10 ATtiny13a's that just arrived from China :-)

p.s. I think Programmer needs to be "Arduino as ISP". Step 5 shows "AVRISP mk2".

Yikes, I knew I forgot something, thanks for pointing that out!

ramoal (author)2017-09-08

Hi, when I clic on Burn Bootloader I've this message:

avrdude: failed to open parallel port "/dev/parport0"

Error while burning bootloader.

jirka krivanek (author)2017-07-09

Great ! It works!

techn0man1ac (author)2017-06-28

Неплохо, понравилось.

Tominaz (author)2017-06-28

near! will definitely look into this. great Documentation

About This Instructable

3,334views

101favorites

License:

More by NotoriousRapper2Chainz:Updated Guide on How to Program an Attiny13a or 13 With the Arduino IDEHow to Make Duct Tape Labels and Decals.
Add instructable to: