Introduction: Programming the ATtiny

Picture of Programming the ATtiny

This is a tutorial for programming the ATtiny chip. This tutorial will be more in depth than most. I will give you every step and tell you the things nobody told me when I first started programming ATtiny.



Things You'll Need

- Arduino Uno( Can be done with other boards but I will be using the UNO)

- ATtiny 85 or equivalent

- 10 uF Capacitor

- Jumper wire

- Breadboard

- LED

Step 1: Software

Picture of Software

First off, we're gonna need the software. If you don't already have it, go to arduino.cc and download the latest version. Next were gonna need to install the ATtiny core files, which are included down below. Open up the arduino software and go to "file" and click on "preferences" take note of you sketchbook location. You'll need it later. CLOSE the IDE, if you don't it won't work until you do. Download the ATtiny core files I've included below. Go into the sketchbook and go to the hardware folder. Drag and drop the "tiny" file into that hardware folder. Now reopen the IDE and click on "tools" and then click on "boards". There should be a whole new set of boards availible including the ATtiny 85. For now, just leave the board as UNO.

Step 2: Arduino As ISP

Picture of Arduino As ISP

Now we need to program the Arduino as an ISP( In-System Programmer). To do this go into the examples and look for ArduinoISP. Open this file and upload the sketch to the UNO as you would with any normal sketch. You have now turned the Arduino into an external programmer. One thing you should check is that you have the right programmer
selected. To do this go to tools and expand the programmer option towards the bottom. Make sure that Arduino as ISP is selected.

Step 3: Hooking Up the ATtiny to the UNO

Picture of Hooking Up the ATtiny to the UNO

Next step, attach the ATtiny to the Arduino.

Arduino Pin Attiny Pin
10 to 1
11 to 5
12 to 6
13 to 7
5v to 8
GND to 4

*note: See pictures for pin configuration of the tiny


Now you need to put the 10uF capacitor between the reset and GND. Be sure to observe polarity( the small negative signs go to ground).
If you don't put the cap in there it won't work.

Step 4: Program the ATtiny

You are now ready to program the ATtiny, but first we need to select our ATtiny chip. To do this, go to "tools" click on "boards" and select the the ATtiny 85 with 1MHz internal oscillator. Don't use any of the ones that say external oscillator because you need to hookup a external crystal of the frequency. We should check to make sure everything has worked. Go into the examples and open the "blink" sketch change the line "int led = 13"; to "int led = 0". Now, in order for the sketch to upload you need to go to "file" and click "upload using programmer" it will start uploading and you will get 2 errors that say "avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85" this tells you that the ATtiny has successfully been programmed. Plug in a LED to pin 5(labeled as pin 0) and connect the negative side to pin 4(GND). It should start blinking at 1Hz. Have fun building and creating with your new tinier arduino.

Some things to note about the ATtiny. It doesn't support all the functions that the UNO does but it does support the following:
- pinMode()
- digitalWrite()
- digitalRead()
- analogRead()
- analogWrite()
- shiftOut()
- pulseIn()
- millis()
- micros()
- delay()
- delayMicroseconds()
- SoftwareSerial

*Another Note: To run the board at 8MHz you must burn the bootloader. To do this, Click on ATtiny 85 with the 8MHz internal oscillator. Click on "tools" and click on burn bootloader. Once that is done the Attiny will run at 8MHz. Doing this will give better timing.

Comments

Djtur3o (author)2015-10-21

For MacOS X and Arduino IDE 1.6.x you should add ATtiny board using Arduino>Preferences>Additional Boards Manager URLs field

The link to ATtiny and other boards URLs can be found here:

https://github.com/arduino/Arduino/wiki/Unofficial-list-of-3rd-party-boards-support-urls#list-of-3rd-party-boards-support-urls

Volthaus Electronics Laboratory made it! (author)2015-01-23

Thanks for the informative Ible. I went ahead and burned the bootloader before I added the blink sketch so the ATtiny85V-10PU will run at 8MHz. It seems a shame to run an IC at a lower speed than it is capable of running. I'm planning on embedding these instead of ATmega328s to save $$$$ money. Thanks!!

AirForce590 (author)2015-01-15

I'm going to order a ton of AtTiny45s from Jameco, as I'm making kits for my Makerspace. I needed to preprogram them with a demo sketch. Thanks!

Raphango made it! (author)2014-08-26

Great man! Many thanks! I made it with na Arduino Nano V 3.0. It's basically the same process.

For in depth explanations, go here:

http://highlowtech.org/?p=1695

Congrats!

NaughtySlayer18 (author)2014-08-18

Yes, you can program it to move a motor. You may have to use a motor driver to drive the motor because the attiny can only source and sink around 40mA of current. But, I digress. all you would have to do is write something similar to the blink sketch to make it move, using an H-bridge to change directions

Gloomysteak096 (author)2014-08-17

will I be able to program this to make a motor move slow or fast in one or the other direction

NaughtySlayer18 (author)2014-07-18

Is there anyway you can copy and paste your code into a notepad file and place it on here?

infanati (author)2014-07-17

I did all that to my ATTiny85 and all i keep getting is OUPUT not declared in this scope

Idrispo (author)2014-04-27

Hey, can you show me your reference on Attiny13 wit Arduino. I'm a newbie here

NaughtySlayer18 (author)Idrispo2014-04-27

Hello, If you download the attached file and put it in the hardware folder. This will give you the Attiny13 as a selectable board from the boards pull-down menu in the Arduino IDE. The ATtiny13 has the same pinout as the Attiny85 and programming it is the same as any other ATtiny. Thanks to diy_bloke for the core files

-Cameron

About This Instructable

10,050views

180favorites

License:

Add instructable to: