How to Program an Attiny85 From an Arduino Uno

67,367

45

26

Introduction: How to Program an Attiny85 From an Arduino Uno

About: I make things, sometimes they break

Quick tutorial showing how to program the ATtiny85 from the Arduino IDE with the help of the Arduino Uno!

This tutorial was requested by my friend Orlando so hope it helps !

Comments,Concerns,Feedback,Requests welcomed:

@NemesisContrer8

Step 1: Add Support for the ATtiny85 to the Arduino URL Board Manager

By default the Arduino IDE does not support the ATtiny85 it's required to add support for the Attiny85 to the Arduino Board Manager:

  • From the Arduino IDE Go to Arduino->Preferences then scroll down to Additional Board Managers URLs
  • Copy & paste the following (if you already have a board manager URL just add a comma before pasting)

Thanks David-one of the Arduino founders for writing the code!

<p>https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json</p>
  • Press "OK" at the bottom then restart the Arduino IDE

Step 2: Install the ATtiny Board Package

  • From the Arduino IDE go to Tools--> Board-->Boards Manager
  • A new tab will open and at the top of the tab type: attiny
  • Select Install on the Attiny by David. A Mellis
  • Restart the Arduino IDE
  • The ATtiny85 board should now be added ! Go to Tools--> Board-->Attiny85

Step 3: Set the Arduino Uno Into ISP Mode

Since what we want is to be able to program the ATtiny85 from the Arduino IDE which requires to burn the bootloader to the ATtiny85 we will need to "prep" the Arduino fist by uploading the ISP sketch to it.

In the Arduino IDE select File-->Examples--> 11. Arduino ISP-->ArduinoISP

the ISP sketch should open and upload it to your Arduino Uno

Step 4: How a Microcontrollers Pins Are Labeled

Before the connections are made there is a very important fact to know how pins on microcrontrollers/ICs are labeled.

Pin numbers used to program a chip on the Arduino IDE are based on how the chip manufacturer has internally named/aranged the pins . The manufacturer of the ATtiny85 is ATMEL (the AT in ATtiny85-actually stands for ATMEL);It's common for chips to have the first two initials of the company who makes them.

Pins are gathered into groups called "ports" these ports are labeled A,B,C etc. Each port has a number of pins which are labeled 0,1,2,3 etc and stick out on different parts of the chip which is why a microcontroller's physical pin often time will be different than the pin number used when programming the chip.


An example:

PB0 (in the above datasheet) just means pin 0 is located on Port B of the Chip.

If pin 0 was located on Port A the name would look something like PA0 (Port A pin 0)

To add to the complexity pins can have more than one fuction and be labeled multiple names.

Wrapping it all together! :

Writing a program to light an LED on pin 0 on the ATtiny85 might be confusing at first because just by looking at the chip , there is no pin 0! However, by checking the datasheet of the ATtiny85 from ATMEL-snippet shown above-pin 0 is internally located on the chip's port B (and is actually the chip's physical pin 5 )!

Step 5: Connecting the Arduino to the ATtiny Pins

Have an electrolytic capacitor-10uF is recommend but I used a 22uF and it worked fine- to prevent the Arduino from restarting it's self connected to GND & RESET on the Arduino

Use a breadboard and jumper wires to make the connections bellow from the Arduino Uno to the ATtiny85:

Arduino--> ATtiny85

5V            Vcc              
GND           GND               
Pin 13        Pin 2
Pin 12        Pin 1
Pin 11        Pin 0
Pin 10        Reset

Step 6: Making the ATtiny85 Arduino Compatible

By default any fresh microcontroller chip bought will not be able to be programmed with the Arduino IDE out of the box. This is why it's required to burn the Arduino bootloader onto the chip to make sure the chip will accept any programs uploaded via the Arduino IDE.

Quick checklist before pressing "burn bootloader"

  • Go to Tools -> Board scroll to the bottom select ATtiny25/45/85
  • Under Tools -> Processor--> 8 MHz (internal)
  • Under Tools-->Programmer-->Arduino as ISP
  • Check that all wiring, capacitor, and board selections are correct
  • Finally select Burn Bootloader
  • leave the wires connected they will be used in the next step

A message will appear saying "Done Burning Bootloader"

Step 7: Uploading the Blink Sketch

Test that the ATtiny85 can now receive sketches from the Arduino IDE by uploading the blink example

  • Go to File-->Example-->01.Basics-->blink
  • Edit the sketch by replacing pin 13 with 0
  • Make sure to still have the ATtiny85 board settings from the previous step selected
  • Make sure all wiring is the same as the previous step
  • Upload the sketch
  • Wire an LED by connecting the anode to pin 0 (physical pin 5 ) and the cathode to a 1K resistor connected to ground (physical pin 4)
  • While a resistor is not needed since the battery provides 3v (not enough to blow up an LED) it is recommended to lower the brightness of the LED

Any request for future tutorials all welcomed! Just leave a comment bellow

5 People Made This Project!

Recommendations

  • Retro Tech Challenge

    Retro Tech Challenge
  • 3D Printed Student Design Challenge

    3D Printed Student Design Challenge
  • Back to School: Student Design Challenge

    Back to School: Student Design Challenge

26 Comments

0
Boli Bordo
Boli Bordo

3 months ago

I am confused because I have a module (processor + other components). Will the connection be the same, particularly the capacitor connecting RST and GND? I need to do some more research.

0
ab6ui
ab6ui

4 months ago on Step 3

Great tutorial. Although I am very familiar with Arduinos this was my 1st attempt at programming an ATtiny-85. I had a problem in Step 3. when I tried to compile the ArduinoISP sketch and got an error. Once I realized the ArduinoIDE was still set up to program the ATtiny NOT the UNO I just changed the board to UNO and then the sketch compiled and downloaded to the UNO without error. One other minor issue was editing the blink sketch. The version of blink I have uses the built in LED so I had to change "LED_BUILTIN" TO "0" in three places. After that everything worked!!!

0
michael_boldt
michael_boldt

8 months ago

Problem solved and got it running. As usual, the problem sat in front of the screen - but to my excuse:
Many Menues from this super Instructable look different on my Mac :-(
I'm running OSX High Sierra and the latest Arduino IDE which is 1.8.13.
To install the newest(?) ATtiny Board Package in the Arduino Pref. Pane I had to enter <http://drazzy.com/package_drazzy.com_index.json> > and download "ATtinyCore 1.4.1 by Spence Konde".
And then it was a matter of trial and error until I got it going, especially you have to upload your code with "upload with programmer" instead of jus hitting "upload". I got cryptic error notes which drove me close to insanity...

Forgive me another lenghty remark: As a beginner in playing with the ATtiny85 , I did not know about the necessity of burning a bootloader. That's why I uploaded the Double-Blink Sketch with and without the option of bootloader burning, then pulled the ATtiny from its socket and wired it with a LED to a 5V Supply. Both of them do, what they are supposed to do, but I had to choose different clock speeds to obtain the correct delays of 100- and 2000ms. Read on here #2:<https://forum.arduino.cc/index.php?topic=522951.0>
For clarification I will enter 3 screenshots of my settings in addition to the video in the "I made it" - section above.

0
mb_lenggries
mb_lenggries

8 months ago on Step 7

would really like to start programming an ATtiny85 but I can not install a bootloader (from whatever source - Micronucleus preferred).
Went through many tutorials within the last 4days - and really liked yours most for readability - but sadly no luck.
Had to delete Oracle Java from the HD, because it prevented the Boardmanager to find and load the ATtiny related files!

I am trying this on a MacBook pro as well on a Mac Mini, both running High Sierra and Arduino IDE 1.8.9 (and 1.8.13) As „Programmer“ an Arduino Uno (Original) and a Chinese Nano Clone with CH340 drivers with both working well in the Arduino Environment as well as all of my USB-cables.
All wirings from Arduino to the ATtnies 8-pin socket were soldered, because breadbord wiring with (my) Duponts is often not reliable, and I did not forgot the 10uF Capacitor (had to temporarily desolder it in order to upload the ISP-Sketch to the Arduinos)!

Do I really have to deinstall the IDE and downgrade to version 1.6.x?

0
jan.krzywanski658
jan.krzywanski658

1 year ago

Why nobody remark that it works with Arduino1,6 ?. How to get possibility to work on computer with higherversion of Arduino

0
sharepksn
sharepksn

10 months ago

Here is a free, no strings attached online simulator for ATTiny85 Arduino coding. You can see all the outputs (LEDs, OLEDs, LCDs, NeoPixels, etc) and inputs such as buttons, Potentiometers, keypads and more).
It is a wokwi Arduino SImulator and is free for all. Please have a look at it.
https://wokwi.com/arduino/projects/283022189068812813


2020-11-30_22h26_04.png2020-11-30_22h27_32.png
0
jan.krzywanski658
jan.krzywanski658

1 year ago

Having problems with Attiny boards installation on Arduino 1.8.5 Is it not compatible UP

0
paruabaypanel
paruabaypanel

1 year ago

Ive tried following other tutorials and no luck, this worked first time!! thanks so much

0
joelelangovan
joelelangovan

1 year ago

Everything worked fine. Thanks for the detailed guide. I used a Attiny85 USB, and the reset pin on it is marked P5.

0
EnriqueV35
EnriqueV35

1 year ago

I MUST send you my heartest congratulation. I have tried more than 4 "tutorials" on ATtiny programing with Arduino that always failed. . . and it wasn't my fault, as it is clearly deduced by my success by following YOUR "instructable" Thank you!

0
ezclimber
ezclimber

1 year ago

Using 2 virgin Atmel ATtiny85 and Uno. Burning bootloader. Precisely followed instructions with quadruple checks on each step. Same result with each chip
Any clues? -- ERROR --
Arduino: 1.8.12 (Mac OS X), Board: "ATtiny, ATtiny85, 8 MHz (internal)"
Error resolving FQBN: board
Error compiling for board ATtiny.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

0
Rousan
Rousan

1 year ago

Having a error ```'Serial' was not declared in this scope``` while running the example .
why is that?..can someone help?

0
jdtran96
jdtran96

Reply 1 year ago

You might have set the board to attiny while attempting to upload rather than having the board set to arduino uno.

0
MarkS928
MarkS928

Tip 1 year ago on Step 1

Had a small issue on the link to copy/paste the damellis file; don't involve the <p></p> codes.
Thanx for the tutorial!

0
WailinSoul
WailinSoul

Tip 1 year ago

You could skip the part to burn the bootloader when you upload a sketch via sketch->upload with programmer (or ctrl-shift-u), but i must compliment you on a very complete and well documented instructable.