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

38,724

148

20

Introduction: 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

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

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

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

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

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

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

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!

5 People Made This Project!

Recommendations

  • Make it Glow Contest

    Make it Glow Contest
  • First Time Author Contest

    First Time Author Contest
  • PCB Challenge

    PCB Challenge

20 Discussions

0
jonas.wolf.1158
jonas.wolf.1158

15 days ago

My Problem :
When i select the Attiny 13 and the Attiny 13a as the Processor i get this Error

avrdude: AVR Part "attiny13a" not found.
Valid parts are:
uc3a0512 = AT32UC3A0512
c128 = AT90CAN128
c32 = AT90CAN32
c64 = AT90CAN64
pwm2 = AT90PWM2
pwm216 = AT90PWM216
pwm2b = AT90PWM2B
pwm3 = AT90PWM3
pwm316 = AT90PWM316
pwm3b = AT90PWM3B
1200 = AT90S1200
2313 = AT90S2313
2333 = AT90S2333
2343 = AT90S2343
4414 = AT90S4414
4433 = AT90S4433
4434 = AT90S4434
8515 = AT90S8515
8535 = AT90S8535
usb1286 = AT90USB1286
usb1287 = AT90USB1287
usb162 = AT90USB162
usb646 = AT90USB646
usb647 = AT90USB647
usb82 = AT90USB82
m103 = ATmega103
m128 = ATmega128
m1280 = ATmega1280
m1281 = ATmega1281
m1284 = ATmega1284
m1284p = ATmega1284P
m1284rfr2 = ATmega1284RFR2
m128rfa1 = ATmega128RFA1
m128rfr2 = ATmega128RFR2
m16 = ATmega16
m161 = ATmega161
m162 = ATmega162
m163 = ATmega163
m164p = ATmega164P
m168 = ATmega168
m168p = ATmega168P
m168pb = ATmega168PB
m169 = ATmega169
m16u2 = ATmega16U2
m2560 = ATmega2560
m2561 = ATmega2561
m2564rfr2 = ATmega2564RFR2
m256rfr2 = ATmega256RFR2
m32 = ATmega32
m3208 = ATmega3208
m3209 = ATmega3209
m324p = ATmega324P
m324pa = ATmega324PA
m325 = ATmega325
m3250 = ATmega3250
m328 = ATmega328
m328p = ATmega328P
m328pb = ATmega328PB
m329 = ATmega329
m3290 = ATmega3290
m3290p = ATmega3290P
m329p = ATmega329P
m32m1 = ATmega32M1
m32u2 = ATmega32U2
m32u4 = ATmega32U4
m406 = ATMEGA406
m48 = ATmega48
m4808 = ATmega4808
m4809 = ATmega4809
m48p = ATmega48P
m48pb = ATmega48PB
m64 = ATmega64
m640 = ATmega640
m644 = ATmega644
m644p = ATmega644P
m644rfr2 = ATmega644RFR2
m645 = ATmega645
m6450 = ATmega6450
m649 = ATmega649
m6490 = ATmega6490
m64m1 = ATmega64M1
m64rfr2 = ATmega64RFR2
m8 = ATmega8
m8515 = ATmega8515
m8535 = ATmega8535
m88 = ATmega88
m88p = ATmega88P
m88pb = ATmega88PB
m8u2 = ATmega8U2
t10 = ATtiny10
t11 = ATtiny11
t12 = ATtiny12
t13 = ATtiny13
t15 = ATtiny15
t1604 = ATtiny1604
t1606 = ATtiny1606
t1607 = ATtiny1607
t1614 = ATtiny1614
t1616 = ATtiny1616
t1617 = ATtiny1617
t1634 = ATtiny1634
t20 = ATtiny20
t202 = ATtiny202
t204 = ATtiny204
t212 = ATtiny212
t214 = ATtiny214
t2313 = ATtiny2313
t24 = ATtiny24
t25 = ATtiny25
t26 = ATtiny26
t261 = ATtiny261
t28 = ATtiny28
t3214 = ATtiny3214
t3216 = ATtiny3216
t3217 = ATtiny3217
t4 = ATtiny4
t40 = ATtiny40
t402 = ATtiny402
t404 = ATtiny404
t406 = ATtiny406
t412 = ATtiny412
t414 = ATtiny414
t416 = ATtiny416
t417 = ATtiny417
t4313 = ATtiny4313
t43u = ATtiny43u
t44 = ATtiny44
t441 = ATtiny441
t45 = ATtiny45
t461 = ATtiny461
t5 = ATtiny5
t804 = ATtiny804
t806 = ATtiny806
t807 = ATtiny807
t814 = ATtiny814
t816 = ATtiny816
t817 = ATtiny817
t84 = ATtiny84
t841 = ATtiny841
t85 = ATtiny85
t861 = ATtiny861
t88 = ATtiny88
t9 = ATtiny9
x128a1 = ATxmega128A1
x128a1d = ATxmega128A1revD
x128a1u = ATxmega128A1U
Fehler beim Brennen des Bootloaders.
x128a3 = ATxmega128A3
x128a3u = ATxmega128A3U
x128a4 = ATxmega128A4
x128a4u = ATxmega128A4U
x128b1 = ATxmega128B1
x128b3 = ATxmega128B3
x128c3 = ATxmega128C3
x128d3 = ATxmega128D3
x128d4 = ATxmega128D4
x16a4 = ATxmega16A4
x16a4u = ATxmega16A4U
x16c4 = ATxmega16C4
x16d4 = ATxmega16D4
x16e5 = ATxmega16E5
x192a1 = ATxmega192A1
x192a3 = ATxmega192A3
x192a3u = ATxmega192A3U
x192c3 = ATxmega192C3
x192d3 = ATxmega192D3
x256a1 = ATxmega256A1
x256a3 = ATxmega256A3
x256a3b = ATxmega256A3B
x256a3bu = ATxmega256A3BU
x256a3u = ATxmega256A3U
x256c3 = ATxmega256C3
x256d3 = ATxmega256D3
x32a4 = ATxmega32A4
x32a4u = ATxmega32A4U
x32c4 = ATxmega32C4
x32d4 = ATxmega32D4
x32e5 = ATxmega32E5
x384c3 = ATxmega384C3
x384d3 = ATxmega384D3
x64a1 = ATxmega64A1
x64a1u = ATxmega64A1U
x64a3 = ATxmega64A3
x64a3u = ATxmega64A3U
x64a4 = ATxmega64A4
x64a4u = ATxmega64A4U
x64b1 = ATxmega64B1
x64b3 = ATxmega64B3
x64c3 = ATxmega64C3
x64d3 = ATxmega64D3
x64d4 = ATxmega64D4
x8e5 = ATxmega8E5
ucr2 = deprecated, use 'uc3a0512'

apperently the Attiny 13a isnt a thing in the Library you used please update or help me fix i am sitting at this problem for 3 days with many tutorials used and nothing worked.

thanks in advance

0
andrea biffi
andrea biffi

1 year ago

Thanks that will be super-useful!

0
PatrickB239
PatrickB239

Tip 1 year ago

I done this with an MEGA2560. Here you have to use (on some fake boards) Pin 10 instead of Pin 53 (SPI)

0
Arif17
Arif17

2 years ago

great Tutorial ever..!

0
Flynns_Place
Flynns_Place

2 years ago

I made this last night and it worked great. I've been looking at other tutorials on how to SIMPLY program the ATTiny13 and most of them contained a bunch of command line operations outside of any useable IDE. Since I had my Arduino Uno sitting around doing nothing, I decided to try it. Thanks for the clear step by step.

Now I can get on with programming it for some of my other projects!

0
Gajeboo
Gajeboo

Question 2 years ago

Thank you very much... Its worked! I did it.
But how to use the other three pins that being used which connected to arduino pins : 13, 12, 11 in program?

This is the link my work :

https://youtu.be/oldyoqBlpY8

0
Gajeboo
Gajeboo

Question 2 years ago

Thank you very much... Its worked! I did it.
But how to use the other three pins that being used which connected to arduino pins : 13, 12, 11 in program?

0
MarcosG19
MarcosG19

3 years ago

Funcionou perfeitamente, muito bom o tutorial!

0
berniegb
berniegb

3 years ago

Arduino: 1.8.5 (Mac OS X), Board: "ATtiny13, ATtiny13a, No (ISP Programmer Upload), 9.6MHz Internal Oscillator, Millis Available, No Tone, Better Or Equal 1.666% Error (Default), Bin, Hex, Dec Supported, Half Duplex, Read+Write, LTO Enabled, 2.7v"

/Users/berniebenson/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9/bin/avrdude -C/Users/berniebenson/Library/Arduino15/packages/diy_attiny/hardware/avr/2017.10.29/avrdude.conf -v -pattiny13 -cstk500v2 -Pusb -e -Ulock:w:0x3F:m -Uhfuse:w:0b11111011:m -Ulfuse:w:0x7A:m

avrdude: Version 6.3, compiled on Jan 17 2017 at 12:01:35

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

Copyright (c) 2007-2014 Joerg Wunsch

System wide configuration file is "/Users/berniebenson/Library/Arduino15/packages/diy_attiny/hardware/avr/2017.10.29/avrdude.conf"

User configuration file is "/Users/berniebenson/.avrduderc"

User configuration file does not exist or is not a regular file, skipping

Using Port : usb

Using Programmer : stk500v2

avrdude: usbdev_open(): did not find any USB device "usb" (0x03eb:0x2104)

avrdude done. Thank you.

Error while burning bootloader.

This is the error info when trying to burn the bootloader.

Any suggestions please

Regards

Bernie

2
ArsS1
ArsS1

3 years ago

When I want to programing

I encountering this error

Arduino: 1.8.1 (Windows 10), Board: "ATtiny13, ATtiny13a, No (ISP Programmer Upload), 9.6MHz Internal Oscillator, Millis Available, No Tone, Better Or Equal 1.666% Error (Default), Bin, Hex, Dec Supported, Half Duplex, Read+Write, LTO Enabled, 2.7v"

Sketch uses 942 bytes (91%) of program storage space. Maximum is 1024 bytes.

Global variables use 34 bytes (53%) of dynamic memory, leaving 30 bytes for local variables. Maximum is 64 bytes.

avrdude: Yikes! Invalid device signature.

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

this check.

An error occurred while uploading the sketch

This report would have more information with

"Show verbose output during compilation"

option enabled in File -> Preferences.

0
BallscrewBob
BallscrewBob

3 years ago

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.

0
ramoal
ramoal

3 years ago

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.

0
NotoriousRapper2Chainz
NotoriousRapper2Chainz

Reply 3 years ago

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

0
ramoal
ramoal

Reply 3 years ago

Thanks a lot it works.

0
PaulH433
PaulH433

3 years ago

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".

0
NotoriousRapper2Chainz
NotoriousRapper2Chainz

Reply 3 years ago

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

0
ramoal
ramoal

3 years ago

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

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

Error while burning bootloader.

0
techn0man1ac
techn0man1ac

3 years ago

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

0
Tominaz
Tominaz

3 years ago

near! will definitely look into this. great Documentation