Introduction: Using the Arduino Uno to Program ATTINY84-20PU

Using the Arduino Uno to program ATTINY84-20PU (Newark item # 68T3783). This Instructable shows how to use the Arduino platform to work with physically smaller processors, such as the ATtiny84 (84/44/24), ATtiny85 (85/45/25), and ATtiny2313. This example is specifically for the ATtiny84-20PU processor (Newark item # 68T3783) but can be adapted for the others boards by selecting the appropriate board from the Arduino software (i.e., Arduino IDE) and modifying the pinouts as required.

Step 1: Configure the Arduino IDE Software

1) Ensure the Arduino software (aka Arduino Integrated Development Environment [IDE]) is NOT running on your computer.

2) Create new folder named "tiny" in your Arduino "hardware" folder
C:\Projects\Arduino\hardware\tiny

3) Download the Arduino-Tiny archive (ZIP-file)
http://code.google.com/p/arduino-tiny/downloads/detail?name=arduino-tiny-0100-0016.zip

4) Copy and paste the contents of the ZIP-file into the "tiny" folder.

5) Create a new file named "boards.txt" in the tiny directory using any text editor. Make sure to save as a text file (.txt).
C:\Projects\Arduino\hardware\tiny\boards.txt

6) Open the "boards.txt" file and the "Prospective Boards.txt" file using a text editor.

7) Copy board entries of interest from "Prospective Boards.txt" to "boards.txt". Or just simply copy the entire contents from "Prospective Boards.txt" to "boards.txt" like I did.

8) Save and close "boards.txt". Close "Prospective Boards.txt" (see picture for how the contents should look).

Step 2: Program the Arduino to Use As an In-System Programmer (ISP)

9 ) Open the Arduino software on your computer (aka Arduino IDE).

10) Select your Arduino board. I have the Arduino UNO but replaced the processor with a pre-programmed Atmega328P chip from Adafruit, which requires that I select "Arduino Duemilanove with ATmega328."

At this point, you should see additional "boards" listed, such as all of the ATtiny boards that as in your "Boards.txt". Do not select the ATtiny chip at this point. Select your Arduino board so that you can tell the Arduino that you want to use it as an In-System Programmer (ISP).

11) Select AVR ISP programmer by selecting [Tools] [Programmer] AVR ISP.

12) Upload the ArduinoISP sketch to your Arduino by selecting [File] [Examples] ArduinoISP. Once uploaded your Arduino will be programmed to be used as an ISP.

Step 3: Create Blink Sketch for the Attiny84

13) Open the sketch to be programmed onto Attiny84. This example uses the Blink sketch from the Arduino software.
[File] [Examples] [01.Basics] [Blink]

14) Edit the sketch so the LED pins correspond to the ATtiny84. That is, change "int led = 13;" to "int led = 0;"

Step 4: Configure the Arduino to Use As an ISP

15) Select ATtiny84 @ 1 MHz (internal oscillator; BOD disabled) by selecting
[Tools] [Boards] Attiny84 @ 1 Mhz (internal oscillator; BOD disabled)

(Note: Do not select a chip for use with an external oscillator unless you have one; it you do so, the chip will not work again until you have connected it to an external oscillator).

Your Arduino is now configured to be used as an ISP.

Step 5: Connect the Hardware

16) Disconnect USB/power from Arduino

17) Connect the Arduino Pins to the ATtiny84 pins.
Arduino 5V to ATtiny84 Pin 1
Arduino Pin 10 to ATtiny84 Pin 4
Arduino Pin 11 to ATTiny84 Pin 7
Arduino Pin 12 to ATtiny84 Pin 8
Arduino Pin 13 to ATtiny84 Pin 9
Arduino GND to ATtiny84 Pin 14
Arduino RESET to 10uF cap
10uF capacitor to GND

Step 6: Use the Arduino As an In-System Programmer (ISP)

18) Connect USB/power to Arduino

19) Upload modified Blink sketch to ATtiny84.

Note: An arvdude message appears - something about PAGEL and BS2 - but it is not an error. The program is uploaded successfully.

Step 7: Use the ATtiny84 As a Stand Alone Chip

20) Disconnect USB/power from Arduino

21) Disconnect hook-up wires between ATtiny84 and Arduino.

22) Hook-up ATtiny to run Blink sketch independently from Arduino:
a. ATtiny Pin 1 to 5V leg, which is the right most leg of the voltage regulator that I used with a 9V battery. Not not connect power source until all connections are made. This way you won't short anything. But just to be complete, the +9V goes to the input leg (left most leg) of the Voltage Regulator, the -9V to Voltage Regulator common leg (middle leg), and 5V output (right leg) to ATtiny Pin 1. But don't connect the battery yet.
b. ATtiny Pin 2 to long leg of LED (I defined this as Pin 0 when writing the modified blink sketch)
c. Short leg of LED to any end of Resistor (I chose 330 Ohm. Any resistor from 100 Ohm to 1000 Ohm should work).
d. Other end of Resistor to Ground
e. ATtiny Pin 14 to Ground

23) Now apply power to ATtiny84 by connecting 9V battery.

Step 8: Use All of the ATtiny84s Pins

I wanted to understand how to use each pin on the ATtiny84 so I added this as well:

24) Disconnect USB/power from Arduino

25) Tell the Arduino you want to use it as an ISP (that is, repeat step 2)

26) Download Blink sketch that uses all available pinouts (https://github.com/maltesemanTS1/ATtiny84-Blink-all-Pinouts.git) or modify your own sketch to use all pins (that is, repeat step 3).

27) Configure the Arduino as an ISP as shown previously in step 4.

Step 9: Use All of the ATtiny84s Pins

28) Hook-up ATtiny84 for Blink-On-Each-Pin sketch.

ATtiny Pin 1: 5V
ATtiny Pin 2: myPins[0]
ATtiny Pin 3: myPins[1]
ATtiny Pin 4: RESET pin
ATtiny Pin 5: myPins[2]
ATtiny Pin 6: myPins[3]
ATtiny Pin 7: myPins[4]
ATtiny Pin 8: myPins[5]
ATtiny Pin 9: myPins[6]
ATtiny Pin 10: myPins[7]
ATtiny Pin 11: myPins[8]
ATtiny Pin 12: myPins[9]
ATtiny Pin 13: myPins[10]
ATtiny Pin 14: GND

Connect ATtiny Pins 1 and 14 to 5V and GND, respectively.
Connect all other ATtiny pins, except ATtiny pin 4 (that;s the reset pin), to an LED
Connect a resistor (between 100 and 1k Ohm) between each LED and GND (actually, you can use just one resistor for all LEDs since this program blinks the LEDs one at a time. But it is safer to build with a resistor for each LED in case you mod the sketch at a later time.)

29) Apply power.

Step 10: Parts List

1. Arduino Uno (Digikey 1050-1024-ND)
2. 330 Ohm 1/4 Watt resistor (from resistor kit, Digikey RS125-ND)
3. 10 uF capacitor (from capacitor kit, Digikey P835-KIT-ND)
4. Breadboard ( Half-size breadboard, Adafruit PID 64)
5. 5V voltage regulator (Digikey 497-12404-ND)
6. 9V battery
7. jumper wire (Breadboarding wire bundle, Adafruit PID 153 or 22 awg solid core wire, Digikey A3051R-100-ND)
8. ATtiny 84 (ATTINY84-20PU, Digikey ATTINY84-20PU-ND)
9. 5mm LED (Digikey 754-1262-ND)

Comments

author
eichenlaubl (author)2017-03-15

Great!

Using this setup, when my sketch includes Serial.print() statements, will they be displayed on my pc?

author
jasonamri (author)eichenlaubl2017-05-31

No, sadly the ATTINY series doesn't support hardware serial. The interface used to program is ICSP. You could use the software serial library and hook it up through an arduino board (with the ATMEGA removed), or use a USB to Serial converter. Take a look at step 3&5 for more details: https://www.instructables.com/id/ATtiny85-ATtiny84-Analog-Pins-Serial-Communication/

author
arjen.gerstel.1 (author)2016-10-04

Hi, thanks for this tutorial. It works now. I had some trouble getting it to work, though. Physical pin 2 on the ATTINY84 does not map to pin0 in the code. Instead, I had to use pin10 in the code as in: digitalWrite(10, HIGH); to make the LED on physical pin 2 blink. I've been pulling out my hair wondering why the LED wasn't blinking.

Thankfully, the sketch to make all LEDs blink did the trick.

Did I miss something?

author
tsant (author)arjen.gerstel.12016-10-04

Well, it's been a long time. But looking at "Step 7: Use the ATtiny84 as a Stand Alone Chip," the photo didn't match the schematic. I believe the schematic was missing a jumper to connect the resistor to AtTiny84 pin 14. The schematic has been corrected. Before thinking about other possibilities, do you think this could have been the source of the problem?

author
arjen.gerstel.1 (author)tsant2016-10-06

No, I don't think the missing jumper is the cause. I routinely use LED's with a current limiting resistor already soldered on.

I did find another site with instructions that has a pinout diagram that matches what I'm seeing: ATtiny44-84.png

author

I think I know what's going on here. I'm using a different set of Board definitions. Of course that could be mapping the phyiscal ports differently.

author
tsant (author)arjen.gerstel.12016-10-04

Here is the correction.

Presentation11.jpgPresentation12.jpg
author
juanmolin (author)2014-08-13

Hi, i've used arduino to program a lot of ATtiny85, no problems. Now i need more pins, then i need attiny84. Connect it to my arduino uno, recheck the connections, select Attiny84 8mhz in boards, load blink example ...
1- burn bootloader = no errors (the same output messages with attiny85)
2- upload sketch = no error (same output messages with attiny85)
and the led is not blinking. Check again, change to 1mhz for test ... same result. Have test with 3 attiny84, with an attiny85 (and selecting the board) it's working.
Why i can't get my led blinking with attiny84?

author
tsant (author)juanmolin2014-08-13

did you mod the sketch and the pins you're physically connected to?

attiny84
ATtiny Pin 1: 5V
ATtiny Pin 2: myPin 0
ATtiny Pin 3: myPin 1
ATtiny Pin 4: RESET
ATtiny Pin 5: myPin 2
ATtiny Pin 6: myPin 3
ATtiny Pin 7: myPin 4
ATtiny Pin 8: myPin 5
ATtiny Pin 9: myPin 6
ATtiny Pin 10: myPin 7
ATtiny Pin 11: myPin 8
ATtiny Pin 12: myPin 9
ATtiny Pin 13: myPin 10
ATtiny Pin 14: myPin GND

attiny 85
ATtiny Pin 1: RSEST
ATtiny Pin 2:
ATtiny Pin 3:
ATtiny Pin 4: GND
ATtiny Pin 5:
ATtiny Pin 6:
ATtiny Pin 7:
ATtiny Pin 8: 5 V

author
juanmolin (author)tsant2014-08-15

Hi gain, now i have blinking led on attiny84!, thanks. Only a question, why pin0 is the attiny pin2? if you search for attiny84 pinout, you can find http://fc04.deviantart.net/fs70/f/2013/038/3/7/attiny_web_by_pighixxx-d5u4aur.png (for example). The Arduino pin0 is located at attiny84 pin 13 o_O

author
mhalstead (author)juanmolin2016-05-12

Hi Juanmolin,
It's been a long time but I only just found your post. Just wondering if you remember what you did to get your attiny84 to work. I have the same problem led blinks with attiny85 but not with attiny84. I've been at it for days trying all sorts of things.

Thanks

author
tsant (author)mhalstead2016-05-13

There are physical differences between 85 pins and 84 pins. So first ensure the proper physical connections with the attiny84, which will absolutely be different from any connections you made with the attiny85. I (re)pasted the pinouts below. Let me know how it goes.

attiny84
ATtiny Pin 1: 5V
ATtiny Pin 2: myPin 0
ATtiny Pin 3: myPin 1
ATtiny Pin 4: RESET
ATtiny Pin 5: myPin 2
ATtiny Pin 6: myPin 3
ATtiny Pin 7: myPin 4
ATtiny Pin 8: myPin 5
ATtiny Pin 9: myPin 6
ATtiny Pin 10: myPin 7
ATtiny Pin 11: myPin 8
ATtiny Pin 12: myPin 9
ATtiny Pin 13: myPin 10
ATtiny Pin 14: myPin GND

attiny 85
ATtiny Pin 1: RSEST
ATtiny Pin 2:
ATtiny Pin 3:
ATtiny Pin 4: GND
ATtiny Pin 5:
ATtiny Pin 6:
ATtiny Pin 7:
ATtiny Pin 8: 5 V

author
tsant (author)juanmolin2014-08-26

naw mean

author
tsant (author)juanmolin2014-08-23

I guess it is a matter of choice. I know in programming they start counting at zero rather than one. So in my sketch I chose to define my first usable Pin as pin0 even though it might physically be a different pin on the attiny (and on the Arduino for that matter). When I define the first useable pin this way, I see the first led blinking and I know it's pin0 in my sketch. And the second blinking led is pin1 and so on. In other words, once the physical connections are made, I'm mostly concerned about the programming, not the physical relation to the pinout diagram of any particular atTinyXX. If you want to define you're pins deferently in your sketch so to match the pinout diagram of the atTinyXX, you certainly can. Whatever you do, just don't confuse the Arduino pins with the atTiny pins with the pin definitions of your choosing that are in your sketch.

author
pdpprd (author)2015-12-24

Great instructable. Worked first time so long you follow the instructions.

I made one mistake - I used the:

ATtiny84 @ 8 MHz (internal oscillator; BOD disabled) option in step 15 and not the:

ATtiny84 @ 1 MHz (internal oscillator; BOD disabled) as specified, thinking it would run eight times faster but it ran the sketch eight times slower i.e. 1 second became 8!!

author
tsant (author)pdpprd2015-12-24

Interesting. I wouldn't have thought that would have happened. Glad it worked anyways!

author
pdpprd (author)tsant2015-12-24

I found the solution to my problem. If you want to use the 8MHz option (and some libraries require 8Mhz and not the default 1MHz) then after step 15 insert 15a which is to select the 8Mhz speed then choose the Burn Bootloader option from the Tools menu. This will set the fuses to allow 8MHz operation.

Source:

http://42bots.com/tutorials/programming-attiny84-a...

I have tested the above and the blink sketch now runs correctly at 1 second.

author
SimonF9 made it! (author)2015-09-30

after a few tries it worked perfectly fine
nice instructable with very good explanations

the arduino in the 2nd picture is only for power supply because i didn't have a voltage regulator at hand

temp_-456906026.jpgtemp_1582680843.jpg
author
tsant (author)SimonF92015-09-30

glad it worked!

author
tsant (author)2015-09-30

hey thanks!

author
FelipeN made it! (author)2015-05-29

it's works :)

2015-05-28 19.25.55.jpg2015-05-28 19.07.40.jpg
author
cwarmski (author)2015-05-09

If using IDE v1.6.4 onwards it is a bit easier (replacing steps 5-8 above), since libraries and hardware can be copied to a local folder. So:

1. Locate the {Sketches} folder as shown in Arduino Preferences:Sketchbook location, e.g. ~/Documents/Arduino/Sketches/

2. If there is no hardware folder create one, e.g. {Sketches}/hardware

3. Copy the tiny folder into there, e.g. {Sketches}/hardware/tiny

4. Restart Arduino IDE

Now the Board appears in the Boards List and the code compiles and uploads fine. No more "Missing Arduino.h" errors!

author
jcone1 (author)2015-04-07

I am getting a compiling error? What am I doing wrong when I try to upload this?

thanks

Blink.ino:16:21: fatal error: Arduino.h: No such file or directory

compilation terminated.

Error compiling.

author
tsant (author)jcone12015-04-07

I'm not totally sure. But clearly the compiler cannot find the Blink sketch. A sketch is a *.ino file.

http://arduino.cc/en/guide/environment

My Blink.ino is located in the Examples menu. I searched my computer to confirm that the Blink.ino sketch is actually located there. I found it at C:\Program Files (x86)\Arduino\examples\01.Basics\Blink

Confirm your sketch is in the directory that it should be for your computer. If not copy it again and save it. From what I've read there may be some subtleties to where you save the Blink.ino so I'd save it in the location that it was originally located, again in my case, C:\Program Files (x86)\Arduino\examples\01.Basics\Blink

http://arduino.cc/en/Tutorial/Blink

Focus on the location of the sketch file and let me know what you come up with. Sorry I can't give a more direct answer.

author
leesmith404 (author)2014-12-18

Thanks for your instructable!

I noticed that ecen for the single LED project you used what looked like a transistor on the breadboard??? Looking at the multiple LED project you mention a


5. 5V
voltage regulator (digikey part number 497-12404-ND)

Is this also used for the single LED?

Can you explain or direct me to a sit which further explains the use and options of a voltage regulator for Ardino?

Thanks in advance, lee

author
tsant (author)leesmith4042014-12-18

Thank you for the comment.

In both examples (one LED or 11 LEDs), there are only the following components:
9 VDC battery
5 VDC voltage regulator (not shown in the photo of example with 11 LEDs, sorry, but it is shown in both schematics)
ATtiny84
LED(s)
resistor(s)

To your point, the voltage regulator is packaged in a TO-220 style package, so it may look like a transistors but it's actually an IC voltage regulator. According the its datasheet, the required supply voltage for the ATtiny84 is between 2.7VDC and 5.5VDC. Since I was using a 9 VDC battery, I needed to step down the voltage. I chose to do this with a simple-to-use voltage regulator. I could have made a voltage divider from a couple of resistors, but I would have to make sure the proper current was also supplied. I didn't want to make things more complicated than necessary, so I went with the Vreg.

Note: the voltage regulator was not required while programming the ATtiny84 because I used the Arduino Uno to power the chip. The Arduino Uno voltage is already at 5VDC, which is within the acceptable range for the ATtiny84.

The use of a voltage regulator is dependent on the design your particular project, the particular components that you're using, and your available voltage sources. For example, if the ATtiny84 could accept a 9VDC source, I wouldn't need the Vreg at all. But this is not the case. The max recommended voltage for the IC is 5.5VDC and I had a 9VDC battery available.

Similarly, if I had a voltage source within the acceptable range of the ATtiny84 (2.7VDC and 5.5VDC) then I would not have needed a voltage regulator at all. I mean I could have wired two AA batteries, which are 1.5VDC each, in series to get 3 VC and not needed the voltage regulator.

A different circuit or a different IC may have entirely difference power or voltage requirements. Even an LED has a min and max recommended voltage (and current). Once you know the power (i.e., voltage and current) requirements of every component in your circuit then you know if a voltage regulator or any other power related device will be required.

author
totof60 (author)2014-11-26

author
jamestav (author)2014-08-20

Nice tutorial! If you want to know how to do this with an Arduino Mega and an ATtiny85, check out my blog at: http://jamestav.blogspot.com/2014/08/programming-attiny85-microchip-using.html

author
tsant (author)jamestav2014-08-23

thx!

author
tsant (author)2013-05-30

Thx!

About This Instructable

118,726views

130favorites

License:

Bio: Mech Eng
More by tsant:Mexican Tile Tablesugru surgery on Umbra Drinking Buddies and TopperCharlieplexing the Arduino
Add instructable to: