Time to shrinkify your arduino projects using the ATtiny-85 chip! In this tutorial, I will be showing you how to use the Arduino Uno as the programmer & arduino software to program the ATtiny85.
What is ATtiny?
ATtiny is a Atmel 8-bit Microcontroller chip, which has 8 pins & 5 of which can be used for programming. It can run from 1.8V to 5.5V, which means that you can power the ATtiny with only a button cell / battery. Furthermore, it is reprogrammable, which means that you can reprogram this chip for other projects! The ATtiny is actually very similar to the arduino board since both are from Atmel, except that it has lesser I/O pins.
The image below shows the pin configuration of the ATtiny85:
Why use ATtiny instead of normal Arduino board?
- Easier to use
- Ideal & convinient for running simple programs (For projects that does not require so many I/O)
How to program the ATtiny-85 chip?
For this tutorial, I would be using the ATtiny 85 chip, although there are other versions such as ATtiny-45, ATtiny-84,etc. We would be a Arduino Uno as a programmer to program the ATtiny85.
The following is required to program the ATtiny:
- Arduino Uno
- Jumper Wires
- 10 uF Capacitor
- Computer with Arduino IDE 1.0
1) Download the Arduino IDE & install it.
2) Open the Arduino IDE. Select File > Examples > ArduinoISP. Upload this file into the Arduino Uno. This program is to convert the Arduino Uno into an AVR ISP (In-System Programmer) for the ATtiny85, which would allow you to burn the bootloader onto the ATtiny85. (Or in other words, program the ATtiny85.)
3) Wire the Arduino Uno & the ATtiny85 using the schematics shown below. Attach a 10uF electrolytic capacitor between the RESET & GND pin, ensuring that the negative part of the capacitor is in the reset pin. (DO NOT REVERSE THE POLARITY!!! PLEASE DOUBLE CHECK THIS BEFORE PLUGGING THE USB INTO THE ARDUINO.) The capacitor is added to prevent the Arduino board from resetting (which starts the bootloader), which ensures that the Arduino IDE talks to the ArduinoISP (not the bootloader) during the upload of sketches into the ATtiny IC.
|Arduino Uno (Pins)||ATtiny-85 (Pins)|
The above table shows you how the jumper wires should be connected if you don’t understand the above schematic. For example, for the first row, what the table means is to connect the Arduino Uno 5V pin to ATtiny pin 8. (Which is ATtiny Vcc pin.) Check that the connections should be similar to the set-up below:
4) Download the ATtiny files here. Extract the folders. Rename the attiny folder (not the attiny-master folder) into “hardware”.
5) Locate your arduino sketchbook location. (Which will most likely be in your documents) Copy & paste the “hardware” folder into it. Restart your Arduino IDE.
6) Go to “tools” > “boards” & select the “ATtiny 85 with 1MHz internal oscillator”. (Don’t use any of the ones that says external oscillator as you need to hookup a external crystal of the frequency.) Next,go to “tools” > “programmer” & select “Arduino as ISP”.
7) Let’s upload a simple program into the ATtiny to checkout whether the Arduino can program the ATtiny.
First, go to the examples and open up the “blink” sketch. Change the line “int led = 13”; to “int led = 0”. What this means is that I’m going to output the signal to digital pin 0, which is pin 5 of the ATtiny.
Press upload. After the upload have completed, you will get 2 errors that say “avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85”. You should not be worried about this error as this tells you that the ATtiny has successfully been programmed. Plug in a LED to pin 5 of the ATtiny 85 (labelled as pin 0) and connect the negative side to pin 4 (GND). It should start blinking at 1Hz.
NOTE: The ATtiny doesn’t support all the functions that the UNO does, but it supports the following:
For more detailed explanation of each steps, visit highlowtech.org, since the steps are based on that website.
Need inspiration on what to do with the ATtiny? Here are some interesting projects I found that you can create with ATtiny85: