Program an ATtiny With Arduino
Intro: 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 electrolytic capacitor
- 220ohm 1/4 watt resistor
- LED
- hookup wire
Please note that some of the links on this page contain Amazon affiliate links. This does not change the price of any of the items for sale. However, I earn a small commission if you click on any of those links and buy anything. I reinvest this money into materials and tools for future projects. If you would like an alternate suggestion for a supplier of any of the parts, please let me know.
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.
Did you find this useful, fun, or entertaining?
Follow @madeineuphoria to see my latest projects.
196 Comments
khatharr 2 years ago
robotsaregood 6 years ago
Does this work with 1.8.5?
randofo 6 years ago
I don't know.
If it doesn't you should be able to download a legacy version of the software. This page has core files available for Arduino 1.5:
https://code.google.com/archive/p/arduino-tiny/
This page has core files for ATTiny 1.6.5 or later:
https://github.com/SpenceKonde/ATTinyCore
AT 11 years ago
avrdude: Yikes! Invalid device signature.
Double check connections and try again, or use -F to override
this check.
When I connect the LED, nothin. :-(
zextron 11 years ago
AT 6 years ago
AT 11 years ago
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 10 years ago
Don't bootloader and use External. It will damages core. I damaged mine.
electron1979 6 years ago
Selecting "External" means you need a external crystal for it to work.
You can add a crystal, reprogram with "Internal" setting and remove external crystal.
iwilliams13 10 years ago
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 10 years 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 11 years ago
AT 11 years ago
AT 11 years ago
randofo 11 years ago
Bris32 6 years ago
thyme4soup 6 years ago
the ATtiny probably wouldn't be able to supply the current necessary to run a servo, try adding a BJT or a MOSFET or some kind of electric switch to take the binary signal from the ATtiny to allow current to drive the servo.
antisuru 6 years ago
did not working on me
Why this happen when i select ATtiny85 (w/ Arduino as ISP)
can not compile
Blink.ino:10:21: error: Arduino.h: No such file or directory
Blink.ino: In function 'void setup()':
Blink:15: error: 'OUTPUT' was not declared in this scope
Blink:15: error: 'pinMode' was not declared in this scope
Blink.ino: In function 'void loop()':
Blink:20: error: 'HIGH' was not declared in this scope
Blink:20: error: 'digitalWrite' was not declared in this scope
Blink:21: error: 'delay' was not declared in this scope
Blink:22: error: 'LOW' was not declared in this scope
sebbithecool1 7 years ago
Would it work with a attiny25?
Nice and easy tutorial!
ishan_ panch 6 years ago
hey does attiny25 work ?