9 May 2012

Programming ATtiny45/ATtiny85 with Arduino

I have found many long winded HOWTOs on doing this, I love mini howtos, here we go:

I am using an Arduino UNO with Arduino IDE 0022.

The Arduino IDE needs some hardware information to support the ATtiny45/ATTiny85. Download the following zip file, create a hardware folder in your sketches folder and unzip it into the newly created hardware folder (you should now have the following folder structure in your sketches folder: hardware/attiny45_85/). Restart the Arduino IDE.

Flash your Arduino with the ArduinoISP sketch (File » Examples » ArduinoISP, compile and upload).

Connect the ATtiny45 or ATtiny85 to your Arduino as shown below:


(use a 10 uF capacitor between reset and ground, - on the capacitor goes to GND).


Pin layout of ATtiny45/ ATtiny85

That's it. Select "Tools » Board » ATtiny45 (w/ Arduino as ISP)" as board and you are good to go. While uploading the Arduino IDE will show the error "avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny45". This doesn't have an effect, just disregard it.

To check if it works you may connect a LED from pin0 to GND and upload the following blink sketch (the LED will also flash on activity during MOSI while uploading a sketch).

// Blink for ATtiny45/ATtiny85 

#define PIN_LED 0

void setup() {                
  // initialize the digital pin as an output.
  // Pin 13 has an LED connected on most Arduino boards:
  pinMode(PIN_LED, OUTPUT);     
}

void loop() {
  digitalWrite(PIN_LED, HIGH);   // set the LED on
  delay(1000);              // wait for a second
  digitalWrite(PIN_LED, LOW);    // set the LED off
  delay(1000);              // wait for a second
}