Program an ATtiny with Arduino

Picture of 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.
Remove these adsRemove these ads by Signing Up

Step 1: Go get stuff

Picture of Go get stuff
You will need:

- Arduino
- Breadboard
- ATtiny85 (or ATtiny45)
- 10uF 16V electrolytic capacitor
- 220ohm 1/4 watt resistor
- 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

Picture of 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

Picture of 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

Picture of 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:

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

Picture of 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

Picture of 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.
1-40 of 125Next »
joesinstructables made it!5 days ago

Thanks for posting the tutorial, it will be useful for a lot of projects.

infanati1 year ago
I've been trying to program my ATtiny13V but I keep getting "'OUTPUT' was not declared in this scope".

// Must include for servos to work
// Elements is the amount of numbers you want to dedicate to the running average
// Increase the number for a slower reaction
#define elements 5

// Variables for loops
int i = 0;
int j = 0;

// The Analog Pins - C:Centre R:Right L:Left U:Up
int pinC = 1;
int pinR = 2;
int pinL = 3;
int pinU = 7;

// Variables to store the data from the photo-resisitors
int analogValueC;
int analogValueL;
int analogValueR;
int analogValueU;

// The change in position from the last reading
float posX = 0;
float posY = 0;

// The running average readings
// - Each element is made up of the difference between opposite photorestors
int x[elements], y[elements];

// Servos - X is rotation/spin, Y is the tilt servo
Servo servoX;
Servo servoY;

// Common servo setup values
int minPulse = 600; // minimum servo position, us (microseconds)
int maxPulse = 2400; // maximum servo position, us

void setup() {

// Turn on the pins, program doesn't work without it *shrug*
pinMode(6, OUTPUT);
pinMode(5, OUTPUT);
digitalWrite(6, HIGH);
digitalWrite(5, HIGH);
delay (200);

// Attach each Servo object to a digital pwm pin
servoY.attach(6, minPulse, maxPulse);
servoX.attach(5, minPulse, maxPulse);

// Sanity check!

// Start all the running average values to zero
for(i=0;i x[i] = 0;
y[i] = 0;

// Serial - good for troubleshooting

void loop() {

// This will help to balance the values so the sun tracker doesn't Jump around
// during high contrast situations
int normal = (analogRead(pinC)/50);

// Read the photorestors
analogValueC = (analogRead(pinC)/normal);
analogValueL = (analogRead(pinL)/normal);
analogValueR = (analogRead(pinR)/normal);
analogValueU = (analogRead(pinU)/normal);
analogValueD = (analogRead(pinD)/normal);

// Check if the Centre photorestor is the brightest, if it is then set the change to zero
if((analogValueC <= analogValueL)||(analogValueC <= analogValueR)){
// Value is positive: go right, negative: go left
x[i] = analogValueR - analogValueL;
} else {
x[i] = 0;
if((analogValueC <= analogValueU)||(analogValueC <= analogValueD)){
y[i] = analogValueU - analogValueD;
} else {
y[i] = 0;

// The change in position is the average of all the elements
int totalX = 0;
int totalY = 0;
for(j=0;j totalX+=x[j];
posX = totalX/elements;
posY = totalY/elements;

// Send the values through the serial when it has gone through all the elements

// Change the position of the tracker towards the light

// Increment I through 0 to number of elements
i = i%elements;

// Class will display a cross on the serial monitor showing real time values of the resistors
void rtDisplay(){
Serial.print(" ");
Serial.println(" /\\");
Serial.print(" <= ");
Serial.print(" => ");
Serial.println(" \\/");
Serial.print(" ");

// Class will display the change in position
void avgDisplay(){
Serial.print(" ");
} else {
Serial.println(" ");
Serial.println(" /\\");
} else {
Serial.print(" ");
Serial.print(" <= ");
} else {
Serial.print(" - ");
Serial.print(" => ");
} else {
Serial.println(" ");
Serial.println(" \\/");
Serial.print(" ");
} else {
Serial.println(" ");

// Named so, because I am planning on making a more complicated verson
void simpleChangePos(){
// Variables to store the current position of the servos
int readX =;
int readY =;

// If there is a change:
// If the servo is going to change position past its range of motion
} else if((readX+posX)<0){
} else {
// If the change is a non-zero and not past the servo's limit, change the position


} else if((readY+posY)<0){
} else {


If anyone got any ideas how to solve it pls let me know : )
randofo (author)  infanati1 year ago
Not all of the code that runs on the Arduino will run on the ATtinys. When you start including libraries, like the servo library, the likelihood of it working diminishes.

Can you program one to blink an LED? If so, the problem is probably with some of the commands you are calling (presumably the servo code). You will need to figure out some alternative way of writing the code, or to modify the library to work with the chip.

I got a new ATTiny85 and and i tried to get it to blink and im still getting the same error. 'OUTPUT' was not declared in this scope.

You need to declare OUTPUT or try to change OUTPUT with 0

doriancin18 days ago

This is a great tutorial!! I have just one question, can I use the EEPROM and WIRE libraries with the ATTINY45 the datasheet says it support the i2c protocol ...

uelman80022 months ago

my question on "Select from the top menu:

Tools --> Board --> ATtiny85 (w/ Arduino as ISP)"

1. Why choose ATtiny85 as the "board" when it is the target chip?

2. Shoudn't it be the Arduino Uno itself as the board?

3. If the chip is possible as the board, why there's no option for Atmega328p in the IDE, setting Arduino as ISP programmer?

how do you unzip the file?

With a program like 7zip or Winrar, obviously.

Armadillo993 months ago

Will this work the same way with an arduino mega?

hydronics1 year ago
yep I get the same error.
randofo (author)  hydronics1 year ago
Are you using the Arduino 1 software? Try downloading an older version of the software - perhaps 5 or 6 versions back. The core files don't seem to play nicely with Arduino 1.
Ok, thanks for the reply. IT WORKS, IT WORKS! I redid everything and it worked and I could not reproduce the error from yesterday, although....
1) Each time you unplug the USB, when you re-connect the USB/Arduino back into your PC, FIRST remove the capacitor...
2) once the computer recognizes the Arduino (2-seconds wait) then replace the capacitor.
3) this was a problem once but then it didn't reoccur...kinda glitchy ;( maybe just my janky setup.

I'm running Windows, Duemilanove to ATTiny85. I got it to work on 1.03 and 1.01. THANKS for this lovely tutorial!! so many projects to do now...

Also, can anyone tell me why the SPI library does not work on Attiny?... I found some code on gethub to get around this but... Can anyone point me to a good reference material for programming that might answer these strange truths that I am oblivious to. My background is Mechanical Engineering and Arduino.
randofo (author)  hydronics1 year ago
Does the library gives errors or just not work? It can be because the registers names are different... or the clock speed of the ATTiny is much slower... or it is using interrupts which the ATTiny does not support... or a host of other reasons. I would have to really look at the library to know.

It depend. Only if you find right ATTiny driver file. Mine work fastest. Be careful to not get wrong hardware file or it will cause 1000 delay from one sec to 10 sec.

Does the ATtiny need to have the Arduino bootloader put on it? Or can any ATtiny straight from digikey be put into this tutorial?

Enjoying Electronics, Pseakins and Crash Plague. This ATTiny85 doens't need bootloader and you wasn't suppose to do that. Bootloader can damages ATTiny as I did. Don't need that Bootloader anyway. Plus, External is bad choose for beginner.

Yep what? It was a two part question. Yep the ATtiny DOES need to have an arduino bootloader, or yep any ATtiny from digikey can be used and therefore does NOT need a bootloader.

So, does it need a bootloader yes or no?
It doesn't matter where you buy it from, digikey, sparkfun, ebay. . .

Just follow the steps in the i'ble and you'll be fine.
Yes, it needs a bootloader
AT1 year ago
This looked like such a cool project. But I am running into an issue that I can't figure out. I get the error once and then it says:

avrdude: Yikes! Invalid device signature.
Double check connections and try again, or use -F to override
this check.

When I connect the LED, nothin. :-(

AT AT1 year ago
I have the 1.0.3 version and switched back to 1.0.1 and getting the same error. I tried the trick that hydronics did but that didn't work either.

I have ATTINY85-20PU
Arduino UNO R3
Board is set to ATTINY 85 (external 20 MHz Clock)
Programmer as Arduino as ISP

Tried Upload and Upload using Programmer

I was able to get the Burn Bootloader to run once with the proper error messages. Nothing else seems to be going as it should.

Binary sketch size: 834 bytes (of a 8,192 byte maximum)
avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85
avrdude: Yikes! Invalid device signature.
Double check connections and try again, or use -F to override
this check.
Jamebonds1 AT4 months ago

Don't bootloader and use External. It will damages core. I damaged mine.

iwilliams13 AT7 months ago
I have used that exact chip and got those errors to rectify it I did this
1 load *ArduinoISP* sketch to arduino board
2 Use ATtiny 85 (internal 1Mhz clock) as board
3 Double check your connections ( i say this because in my case I had reset connected to pin 9 instead of pin 10 when `i got this error)
4 Load a simple sketch like Blinky to see if it works
AT iwilliams135 months ago

I hope to get back to this project at the end of Feb. Thank you for the information. I was so excited about getting some stuff running on the ATtiny 85. I look forward to getting something to work! :-)

randofo (author)  AT1 year ago
Go even further back... Arduino 1.0.anything is not going to work. Go back to version 20 or earlier of the old IDE. For some reason the core files do not work with the new version. Unclear whether anyone is ever going to make an updated set of core files.
AT randofo1 year ago
I loaded up 20 and 22. These are working even worse. I can't even get the blink program to compile fore the ATTiny85. :-(
AT randofo1 year ago
That you for the tips. I will see about getting an older version. I have tried doing 1MHz and 8MHz and was getting the same issue. I will give these a try and comment back.
randofo (author)  AT1 year ago
Also, try it without setting the external clock. Try using the slowest possible internal clock. Sometimes the external clock causes strange errors until you get it configured correctly.
zextron AT1 year ago
I had your error with a tiny85 that I've already used to try this project earlier in 2012, but I think it was fried or I fried it, because then I tried with the same exact config but another one and it was up and running!
Jamebonds14 months ago

Great! Thank for tip! It work with 1.0.5 RC2 which is weird. Don't bootloader on ATTiny 85 as it will damaged core!

ironheartbj186 months ago
Hello i followed your inscrutable It does not working it said 'OUTPUT' was not declared in this scope. What does it mean?

I downloaded the file attiny45
open up the zip file and copy the attiny-45-85 directory in to Arduino 1.5.5 /hardware. please help thanks!
i found out arduino verison 1.0.5 having problem core for attiny 85. best using arduino 0022 its work with core file.
i dont follow at
i followed at
neowton10 months ago
i had the "not in scope trouble" and I fix it, first of all, I try with the latest version of Arduino 1.5.4 at this time and the soft don`t recognize any core files. Also, I download the Arduino 1.0.1 ( on an Mac with Mountain Lion ) and the recognition problem has gone.

Before, the ArduinoISP doesn't work with the core files in attiniy_45_85 folder zip.

I fix it only replacing the core files from the package the google site called

richi52711 months ago
I got a "avrdude: stk500_getsync(): not in sync: resp=0xff" after fallowing these steps. There is also a 1MHz and 8MHz in the boards.txt for target. I tried both and it failed with the above error on a windows 7 machine and an UNO.
timbit19851 year ago
Did you use the manufacturers pin designation for the chip or start counting at the dot and work your way around?
timbit19851 year ago
Nice job! I did a tutorial on how to do an atmega. I have a few attiny's I was looking at today and wondering if the process of programming them was the same. Thank you for putting together such an informative project :) here is mine if you are interested.
eliobou1 year ago
Can I use a 10V 10uF capacitor ?
DirtyMex1 year ago
great project. Is there a possibility that you can program a PICAXE 08m2 using the same steps? If you could help that be of much help
1-40 of 125Next »