loading
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
- LED
- solid core hookup wire

Step 2: Wire the circuit

Picture of Wire the circuit
2B.jpg
2C.jpg
2D.jpg
2E.jpg
2F.jpg
2G.jpg
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
4A.png
4B.png
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.
1-40 of 175Next »
MontezumaG6 days ago

Please help!!!

How can you programm an AATTiny24.

i can't find libraries.

Thanks

MontezumaG6 days ago
TimRogers10 days ago

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

Thanks for the great Instrucatble.

aizozeo1 month ago

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

hypnocool1 month ago

*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?

arduino was defective... i bought a nano instead

BuffaloFan32 made it!1 month ago

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

IMG_1113.JPG

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!

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

jplaiss2 months ago
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?

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.

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.

badjoby2 months ago

Thanks for the instructions. I could make it.

maniacse3 months ago

Thanks mate, this will be very useful for me. I need to learn programing, since everything I want is too pricy or not exist at all.. :)

DavidS403 months ago

For the breadboard CHEAP and perfect for this project, go to e-bay and search

5pcs-Universal-170-Tie-point

breadboard.JPG
DavidS40 made it!3 months ago

Thanks for this, it was INVALUABLE. I'd bought 3 different ATtiny programmers, none of which worked with win7-8... which I found somewhat disturbing/frustrating yet hilarious in the end. THIS, this simple instructable, took me 20 minutes to get a working programmed ATtiny. THANK you.

AND... for Arduino fans, here's the neatest serendipitous event regarding the ATtiny and Arduino... Check out the pic, this breadboard 'accidentally' fits PERFECTLY between the Horizontal arduino female pinouts, AND the vertical caps and end male pins! I kid you not, it fits in, and TIGHT, so you can just pop in a breadboard on an Arduino! I was so thrilled I nearly choked on my coffee when it popped in. Check out the pic!

Okay, I did have to grind off the little plastic doohicky that lets the breadboards stack... but it was worth a few seconds on the grinder.

ATtiny breadboard.JPG
rgonzález pacheco lópez made it!3 months ago

I made a little board with an IC socket and just soldered the 10uf cap onto it as well for quick and easy programming, as I have a bunch of ATTiny85s.

Wires came from patch cord, so bear with me on that.

ATTiny85 works like a charm (did not catch the led on in the pic, but it is blinking on pin 0).

Thanks! Cheers.

IMG_20150416_144008.jpgIMG_20150416_155459.jpg
pixelworlds made it!4 months ago

As a shield for reusability

IMG_4355.jpgIMG_4356.jpgIMG_4357.jpg
pixelworlds made it!4 months ago

Using a 10uF capacitor between the reset and ground pins on the Arduino prevented the IDE from recognizing the board for me - otherwise, everything worked perfectly!

IMG_4354.jpgIMG_4353.jpg

There has got to be an easier way to program a chip to slow down an electronic flash. I downloaded, I unzipped, I followed the directions as they were given here and on the High low tech tutorial, all i was able to accomplish was to change the rate of blink on the Arduino board. The LED wouldn't blink........arggghhhhhh. Anybody know an easy way to slow down an electronic flash?

MohanR34 months ago

Here I found a simple Attiny85 shield which makes the Job Much simpler without any jumper wires.

http://www.htlinux.com/product/attiny-isp-shield/

AT5 months ago

Finally! After 3 years, I got my ATtiny to blink a light. I have an 85-20. To get it working I added the Arduino.h and WProgram.h includes (not sure they helped or not) and I ran this as the board as the 1 mhz not the 20.

I also found that my HIGH and LOW for the digitalWrite are backwards. I am running the basic blink program and when I changed the delay to it would blink for a shorter time of on and a longer time of off, it was backwards.


digitalWrite(led, HIGH);

delay(25);

digitalWrite(led,LOW);

delay(975);

This code had the led on for 975 and off for 25. When reversed the HIGH and LOW, then it worked as I originally expected.

Another major issue I have run into is that some of the ATtiny85 chips are bad. I have two that won't work with this set up and one that does. I have 2 more that I am going to try.

tomvonmom5 months ago

I see you connecting the diode to +5V. Doesn't it fry the micro controller? In my head I would rather go Pin 0 -> diode -> 220ohm -> GND

Thanks for taking the time to put this up. Worked for me.

DSC00496.JPG
samdevsung6 months ago

can i get the hardware files for atmega8 pls!

samdevsung6 months ago

can i get the hardware files for atmega8 pls!

samdevsung6 months ago

can i get the hardware files for atmega8 pls!

samdevsung6 months ago

can i get the hardware files for atmega8 pls!

gnuton6 months ago

Here is the updated tutorial http://highlowtech.org/?p=1695
and do not use the attiny45_85.zip listed in this page but the one you can find in the link I provided to you! cheers!

infanati2 years 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
#include
// 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);
delay(200);

// Sanity check!
servoX.write(90);
servoY.write(90);

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

// Serial - good for troubleshooting
Serial.begin(9600);
delay(200);
}

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];
totalY+=y[j];
}
posX = totalX/elements;
posY = totalY/elements;

// Send the values through the serial when it has gone through all the elements
if(i==0)avgDisplay();
//if(i==0)rtDisplay();

// Change the position of the tracker towards the light
simpleChangePos();

// Increment I through 0 to number of elements
i++;
i = i%elements;
delay(301);
}


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

// Class will display the change in position
void avgDisplay(){
Serial.print(" ");
if(posY>0){
Serial.println(posY);
Serial.println(servoY.read());
} else {
Serial.println(" ");
}
Serial.println(" /\\");
if(posX>0){
Serial.print(posX);
Serial.println(servoX.read());
} else {
Serial.print(" ");
}
Serial.print(" <= ");
if((posX==0)&&(posY==0)){
Serial.print("C");
} else {
Serial.print(" - ");
}
Serial.print(" => ");
if(posX<0){
Serial.println(-posX);
Serial.println(servoX.read());
} else {
Serial.println(" ");
}
Serial.println(" \\/");
Serial.print(" ");
if(posY<0){
Serial.println(-posY);
Serial.println(servoY.read());
} else {
Serial.println(" ");
}
Serial.println();
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 = servoX.read();
int readY = servoY.read();

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

}
delay(15);
}

if(posY!=0){
if((readY+posY)>180){
if(readY!=180){
servoY.write(180);
}
} else if((readY+posY)<0){
if(readY!=0){
servoY.write(0);
}
} else {
servoY.write((readY+posY));
}
delay(15);
}

}

If anyone got any ideas how to solve it pls let me know : )

i know this is old, but cant run the servo library on the tiny.

there is a library called servo8bit.h thas written for the tiny

randofo (author)  infanati2 years 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

ironheartbj18 made it!7 months ago

much nicer to have a breadboard what I made it.

20141224_173914.jpg20141224_173925.jpg20141224_173933.jpg20141224_173950.jpg
lavoslava7 months ago

I try to connect (for the first time!) Arduino Yun with ATtiny45 and try Blink example. Which version of Arduino software should I download and ? Where I can get the schematic - how to connect the jumperwires from Yun to breadboard? Thanks!

Dr_Quark7 months ago

I was initially interested in the concept of ATiny, but after looking at the program memory limit and the required discrete parts required to get an ATiny project running, I don't see much advantage over using a Pro Mini (except if it replaces a lot of discrete gate logic). For example, including SoftwareSerial.h and DallasTemperature.h balloons code to about 6700 bytes, so even in a ATiny85, there's not much room left for user code. There are also limitations on the code that an ATiny can run. Can someone comment or provide examples where the ATiny has a critical advantage over the Pro Mini?

SvenH8 months ago

does anyone know why it says this?

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

I had this problem. My issue was that I hadn't uploaded the Ardunio ISP code in step 3

1-40 of 175Next »