Yes, this is yet another tutorial on how to program an ATTiny with Arduino, but time changes, things are evolving fast, and tutorials need to be updated.
This is a very short and concise tutorial, so I won’t explain what an ATTiny is and why it is useful to program it with an Arduino, as these argument are largely covered. Here you will find instructions on how to program an ATTiny85 (or 45) with an Arduino Leonardo, Arduino Yún, Arduino UNO and Diecimila with the most recent version of the Arduino Software (1.5.x)
You will need:
- Arduino Leonardo, Yún, UNO or Diecimila
- A Breadboard
- Hookup wire
- ATtiny85 (or ATtiny45)
- 10uF 16V electrolytic capacitor (for Arduino UNO or Diecimila)
- 220ohm ¼ watt resistor
First of all, you will need to download the Arduino Tiny plugin from here, so your Arduino software will be able to program the ATTiny.
If you want to make it work with Arduino 1.0.x software, just download this file instead!
Then unzip it and copy the “Tiny” folder into an “hardware” folder that you have to create into your sketches folder.
The final result sholud be
Inside the “tiny” folder, you will find an “avr” folder. Inside this folder, there is a file named “Prospective Boards.txt”. Just rename it into “boards.txt”
When you will start the Arduino Software, you will find new boards under the Tools > Board menu, as in this picture.
Now we have to make the proper connections between the Arduino Board and the ATTiny
Arduino PIN 10 --> ATTiny Reset PIN Arduino PIN 11 --> ATTiny PIN 0 Arduino PIN 12 --> ATTiny PIN 1 Arduino PIN 13 --> ATTiny PIN 2 Arduino GND PIN --> ATTiny PIN GND PIN Arduino +5V PIN --> ATTiny PIN VCC PIN
as in the picture below
or for Arduino Leonardo/Yún
Arduino PIN 10 --> ATTiny Reset PIN Arduino ICSP MOSI PIN --> ATTiny PIN 0 Arduino ICSP MISO PIN --> ATTiny PIN 1 Arduino ICSP SCK PIN --> ATTiny PIN 2 Arduino GND PIN --> ATTiny PIN GND PIN Arduino +5V PIN --> ATTiny PIN VCC PIN
Open the File > Examples > ArduinoISP Sketch and upload it on your Arduino
Only fo these platforms, you have to make this changements to the Arduino ISP sketch, BEFORE uploading it
// January 2008 by Randall Bohn // - Thanks to Amplificar for helping me with the STK500 protocol // - The AVRISP/STK500 (mk I) protocol is used in the arduino bootloader // - The SPI functions herein were developed for the AVR910_ARD programmer // - More information at http://code.google.com/p/mega-isp #include "pins_arduino.h" #define RESET 10 #define LED_HB 13 #define LED_ERR 8 #define LED_PMODE 7 #define PROG_FLICKER true
Now upload it to your Arduino.
Load the File > Examples > 01.Basic > Blink Sketch, and change this line
int led = 13;
int led = 0;
this is because the ATTiny has only 6 output pins (0,1,2,3,4,5) and so we will use the pin 0 instead of the pin 13
Choose the proper board settings (i.e. Attiny85 @ 1Mhz), then choose Tools > Programmer > Arduino as ISP. Now you can upload the “blink” example to the ATTiny85
If everything went fine, you will see something like
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
in the output window of the Arduino Software. Don’t care about the warnings, they’re normal.
If something went wrong, you will find a message like
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.
This means that you have to check your connections again, it happend a lot to me the first time I tried to use an Arduino Leonardo instead of an Arduino UNO, because the ICSP Pins are mapped in a different way on the Leonardo/Yún boards.
Now we can test it! To build a simple test circuit, for the “blink” example, just build this simple circuit
When you power up the ATTiny85, the LED sholud start blinking.
I hope this tutorial is useful to you as it would be useful to me if I was able to find one: I got more then an headache trying to put all the pieces together: the proper plugins, the connections and the little software modifications…