Introduction: Program an ATtiny With Arduino

Follows are directions for programming the ATtiny microcontrollers using the Arduino IDE. In plain English, this is how to program 8-pin Atmel chips as you would normally an Arduino. This is cool because the ATtiny is tiny, and - well - this allows you to make tiny things that don't need a big ol' microcontroller.

The instructions I have posted here are pretty much the same as instructions given by the incredibly awesome High-Low Tech Tutorial. I posted my version of the instructions here because I plan to make a couple of upcoming projects using ATtiny chips and figured I would show my process.

Step 1: Go Get Stuff

You will need:

- Arduino
- Breadboard
- ATtiny85 (or ATtiny45)
- 10uF 16V electrolytic capacitor
- 220ohm 1/4 watt resistor
- LED
- solid core hookup wire

Step 2: Wire the Circuit

Connect the Arduino to the ATtiny as follows:
  • Arduino +5V      --->  ATtiny Pin 8
  • Arduino Ground --->  ATtiny Pin 4
  • Arduino Pin 10   --->  ATtiny Pin 1
  • Arduino Pin 11    --->  ATtiny Pin 5
  • Arduino Pin 12    --->  ATtiny Pin 6
  • Arduino Pin 13    --->  ATtiny Pin 7

Step 3: Program the Arduino

Select the "ArduinoISP" sketch from the "Examples" menu.

Upload the sketch to your Arduino as you would any other sketch.

Your Arduino is now configured as a serial programmer that can program other chips.

Step 4: Filter Cap

Put the 10uF capacitor between ground and the Arduino reset pin. Make sure to keep an eye on the capacitors polarity (ground to ground!).

It is rumored you only need this for the Arduino Uno, but I have found it helped matters to include it with earlier versions as well. If you find that it is not working in the next steps, simple remove it and see if that helps.

Step 5: ATtiny Core Files

Take note of your sketchbook folder from the Arduino preference menu.

Create a new folder in your sketchbook folder called "hardware"

Then, go to this page and download the file: attiny45_85.zip

Unzip this file and leave it in the new hardware folder.

Finally, restart the Arduino programming environment. The new cores should now be loaded.

Note that there are also core files for a number of other ATtiny chips. This page is a good starting point for interfacing with a wide range of them using the Arduino.

Step 6: Program the ATtiny

Select from the top menu:
Tools --> Board --> ATtiny85 (w/ Arduino as ISP)

(Of course, you will want to select a different chip for this if you are using one.)

Then open the basic blink example and change the pin number from 13 to 0.

Finally, upload it as you would any other sketch.

It should give the following error twice:
avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85
avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85

Simply ignore the error message and you should be good to go.

Step 7: Test Circuit

Connect a 220 ohm resistor to pin 5.

Connect an LED between the resistor and +5V.

It should blink.

Congratulations. You're done.

Comments

author
sebbithecool1 made it! (author)2016-05-31

Would it work with a attiny25?

Nice and easy tutorial!

author
ishan_ panch made it! (author)ishan_ panch2017-06-25

hey does attiny25 work ?

author
sebbithecool1 made it! (author)sebbithecool12017-06-27

yes it does, if you use the right settings

im sorry, its a long time since i did this so i dont remember the settings. Also you have to use another library.

author
DadVentor made it! (author)2017-03-15

Thanks for the guide! I add the "heartbeat" "error" and "programming" status led's found in the AruduinoISP sketch.

FirstATtiny.jpg
author
JustinLovesTheTech made it! (author)2017-03-10

So when I unzip the folder and restart the IDE, then open the board manager it just gives me the error "No valid hardware definitions found in folder attiny45_85" Any ideas??

author
dlchambers made it! (author)2017-03-04

With ATtiny45, I find that the Arduino IDE's Clock setting has no effect - the instruction time is always 1us regardless of whether I set Internal clock to 1 or 8 or 16MHz.

Anyone else seen this? Any workarounds? I need the faster instruction cycle from a 16MHz clock.

author
SimonK97 made it! (author)2017-01-04

So I just have a few 100uF capacitors...

Do they work as well?

author
AsifK4 made it! (author)2016-07-10

will a resistor of 10uf 50 V work

author
DanteM13 made it! (author)DanteM132016-12-25

Hi, I hope you understand that a resistor is one kind of component and a capacitor is onother. And yes a capacitor with a value of 10uf and 50 V should work very well :)

author
ChriseanA made it! (author)2016-07-01

avrdude: Yikes! Invalid device signature.

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

this check.

Why does this message appear? :( I can't upload the sketch to attiny85

author
JánM3 made it! (author)JánM32016-10-31

Hi Chrisean, Did you solved your problem somehow? I have the same here.. :((

author
aashi7 made it! (author)2016-10-09

how can I reprogram Attiny 13 ?

author
NghĩaT12 made it! (author)2016-09-01

Can this download program for Attiny13 ?

author
sekramer10 made it! (author)2016-06-29

Do you need to do anything with a bootloader?

author
Kepp27 made it! (author)2016-06-13

Used Arduino 1.6.5. Connected the pins, ran the ArduinoISP. Did not download the attiny85 files in this tutorial. Instead added this "https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json" to additional boards in File->preferences. Downloaded the newest ATtiny plugin from Tools->Board:->Boards Manager->search "ATtiny" and installed newest version. Found this via the original page: http://highlowtech.org/?p=1695 Uploaded the blink program. The timing was completely off as I had picked a clock of 8 MHz internal and by default it runs at 1 MHz. Which would explain why it was like 8 times slower. Burned new bootloader. Uploaded blink program again and now it works perfect!

IMG_20160613_122218.jpg
author
carlos.j.rincon1 made it! (author)2016-06-10

Hi, for the ATtiny84A exist Bootloader?

author
HayderA8 made it! (author)2016-04-27

Hello

After this procedure ,how can i add these code into microcontroller?

#include <avr/io.h>
int main(void)
{

DDRB = 0b00000001; //Data Direction Register setting pin0 to output and the remaining pins as input
PORTB = 0b00000001; //Set pin0 to 5 volts
while(1)
{//Code would be in here if it needed to execute over and over and over ... endlessly

}
}

author
JamesZ16 made it! (author)2016-04-14

thank you so much. and yes high-low tech is an awesome site for this kind of stuff. basically every idea i have an uno is too large to be practical.

this is my first step to making the things i want to make rather than making things others have already made and was made just to learn.

(though i have a whole lot to learn and look forward to it)

thanks again will be checking out your "Tiny" builds next.

20160414_192716.jpg
author
JamesZ16 made it! (author)JamesZ162016-04-18

lol wanted to program more and got the dreaded errors:

stk500_getsync(): not in sync: resp=0x00.

set it up the exact same way.... 10uf and all.... triple checked everything....

very annoying how unreliable this sort of method is and i have a $3 ATTiny 85 programmer but it doesn't work... i need to make a shield...

author
JamesZ16 made it! (author)JamesZ162016-04-21

figured it out again..... somehow.....

regardless, now that i have more than one uno to work with (6 actually and a mega) i am going to make a permanent shield once my 8 pin IC sockets arrive which haven't even shipped yet even though i ordered them over a month ago... (gotta be careful what and when i need something when buying from china) though just ordered some more from a US vendor and will be here in 3 days so that will be a fun project (nice break in between studying for finals) as i will go through them fast enough

author
elexhack made it! (author)2016-03-31

AtTiny85 does not have Arduino boot loader in it, then how does it understand functions like digitalWrite(), analogWrite() and all other functions that are only used in Arduino programming and not in embedded C?

author
eddiea6987 made it! (author)eddiea69872016-04-07

that is what this instructables does, it puts the bootloader in it so it can understand those functions

author
MarkS366 made it! (author)2016-03-17

Is there a good article that explains how to best utilize pins. For example, I have an Uno with a lot of digital and analog pins. I'm not really sure how to make it all work with this smaller CPU.

author
matti.virta.1 made it! (author)2016-02-26

thanks working whit version arduino ide 1.6.7 but not has tools-boards-attiny as isp. but have only attiny and i use thats, load sketch good and blink working. thanks.

proplem has first only were found bootloader and burn thats, then all ok.make new folder "hardware" and copy these tiny files.then working :)

author
MatteoG3 made it! (author)2015-08-21

i've this error...

avrdude: Yikes! Invalid device signature.

I don't know what i've to do....

i've tried a lot of things but without solutions....

Please help me!!!

author
anerdkb16 made it! (author)anerdkb162016-02-07

I got the same error and what solved it is as follows. Press continuously the reset button on the arduino. While doing so take out the usb cablw out of the pc for a few secs and then put it back in (while still pressing the reset button) then upload your attinny85 sketch and only then while it uploads release the reset button on the arduino. Let us know how it works. Good luck!!

author
AndreasB2 made it! (author)2016-01-21

The shield works great!

Thank you for making this guide!

IMG_20160121_232406.jpg
author
cosmicr made it! (author)2016-01-18

Thanks I got it working no problems, but how come the LED is connected to 5v and not to ground? Does it make a difference?

author
Fezder made it! (author)2015-12-31

Yup, with that newer zip works like charm. Thanks for this 'ible!

IMG_1094.JPGIMG_1093.JPG
author
demidroll made it! (author)2015-12-29

it's easy with tutorial. IDE 1.6.9 hw https://github.com/damellis/attiny/tree/ide-1.6.x

Thanks

2015-12-29 17.39.13.jpg
author
pepelephew made it! (author)2015-09-04

Great Tutorial... Thanks...

2615.jpg
author
AngelZ4 made it! (author)AngelZ42015-11-06

bro that looks awesome, is there an instructable for this?

author
AlexP71 made it! (author)2015-10-13

WARNING: This tutorial is now out of date. The zip you are instructed to download is not compatible with the current release of Arduino (1.6.5). Also this tutorial does not mention burning the boot loader to the ATtiny - I found this was required before I could upload sketches. There is an updated version of the original High-Low Tech tutorial linked in this Instructable which did work for me:

http://highlowtech.org/?p=1695

Hope this helps somebody!

Alex

author
andreasp11 made it! (author)2015-09-10

i want to get a pulse in output of attiny45, do u know any code for it? or some link?

author
pradeepss made it! (author)2015-09-05

Made it. Easy tutorial. Note: didn't need the 10uf capacitor.

15, 7:25 PM.jpg
author
KKing88 made it! (author)2015-08-30

got the core files to load but now the IDE isn't recognizing any of the calls... getting errors like

"delay was not declared in this scope"

its for evrything?!? dunno HELP

author
MatteoG3 made it! (author)2015-08-21

author
TimRogers made it! (author)2015-07-21

Can I use a 22uF capacitor? That's the closest I can find at hand.

Thanks for the great Instrucatble.

author
DayvsonR made it! (author)DayvsonR2015-08-21

it think so, I am using two of 4.7uf in parallel and works, the capacitor is to avoid the reset in the upload

author
DayvsonR made it! (author)2015-08-21

Cool

if you are using Arduino IDE 1.6.5 read this http://highlowtech.org/?p=1695, it is the same but more simples.

20150821_075504.jpg20150821_075540.jpg
author
MontezumaG made it! (author)2015-07-25

Please help!!!

How can you programm an AATTiny24.

i can't find libraries.

Thanks

author
aizozeo made it! (author)2015-06-29

i got a problem, the program is fine, and i uploaded blink program perfectly with errors

avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny45
avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny45

but led is still not blinking,

i've changed the pins from 13 to 0, still doesn't work, i'm using arduino 1.0.6 and arduino nano, thank you and sorry for my bad english

author
hypnocool made it! (author)2015-06-18

*I cant write to my ATtiny...can't upload... changed USB, all parameters correct. Im using windows 7 home edition... maybe bad attiny? how to find out if my tiny is working? prior sending data?

author
hypnocool made it! (author)hypnocool2015-06-22

arduino was defective... i bought a nano instead

author
BuffaloFan32 made it! (author)2015-06-07

good instructable, only problem I had was the missing Arduino.h file. I posted a work around below.

IMG_1113.JPG
author
abhinavonowinew made it! (author)2015-04-23

Hey everyone!

I have tried uploading the blink program on the arduino (i have selcected ATTiny 85 w/ Arduino as ISP option)

Arduino shows me this error whiile compling!

Blink.cpp:8:21: fatal error: Arduino.h: No such file or directory

compilation terminated.

Please help!

author
BuffaloFan32 made it! (author)BuffaloFan322015-06-07

I had the same problem until I found this:

Create an Arduino.h in ...\Arduino\hardware\attiny45_85\cores\attiny45_85 containing

#include<WProgram.h>

at this link:

http://electronics.stackexchange.com/questions/87328/arduino-as-isp-for-attiny

author
jplaiss made it! (author)2015-05-29

How critical is the capacitor?
would variation in the uf our volt be more forgiving?
I have a 10 uf 25v cap available. safe our no?

author
ThijssjihT made it! (author)ThijssjihT2015-06-02

Higher voltage rating is almost always safe, if not always. In this case, you can use your 10µF 25V cap, no problem.

In this case, the capacitor is needed to sink an reset signal. I think a higher capacity cap would also work, but I'd stick with 10µF to be sure.

author
jplaiss made it! (author)jplaiss2015-06-02

Much appreciated. I have some 85's on the way and one 328 in hand I can't wait to get back to. Schedule is too tight right now. Adult in school after work.

About This Instructable

524,463views

1,133favorites

License:

Bio: My name is Randy and I founded the Instructables Design Studio. I'm also the author of the books 'Simple Bots,' and '62 Projects to ... More »
More by randofo:Sponge BotSingle Motor BotChocolate Peanut Butter Fudge Recipe
Add instructable to: