Robotics

Robotics

How to program ATTINY 45/85 with Arduino



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 16V electrolytic capacitor
- 220ohm 1/4 watt resistor
- LED
- 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









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.



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.