Introduction: How to Program the ATtiny85 With the Arduino Uno Board

Picture of How to Program the ATtiny85 With the Arduino Uno Board

In this tutorial we will use an Arduino board as an ATtiny programmer.

To do this we will use one Arduino UNO board as an ISP (programmer) and one ATtiny85 micro-controller.

We will use Codebender - online Arduino IDE.

With the following procedure you will be able to program easily the ATtiny45 and ATtiny85 micro-controllers.

So, let's get started!

Step 1: What You Will Need

Picture of What You Will Need

For this tutorial you will need:

  • Arduino uno
  • Breadboard
  • ATtiny85
  • 10 uF capacitor
  • jumper wires

Step 2: About the ATtiny85

Picture of About the ATtiny85

From Atmel:

The high-performance, low-power Atmel 8-bit AVR RISC-based microcontroller combines 8KB ISP flash memory, 512B EEPROM, 512-Byte SRAM, 6 general purpose I/O lines, 32 general purpose working registers, one 8-bit timer/counter with compare modes, one 8-bit high speed timer/counter, USI, internal and external Interrupts, 4-channel 10-bit A/D converter, programmable watchdog timer with internal oscillator, three software selectable power saving modes, and debugWIRE for on-chip debugging. The device achieves a throughput of 20 MIPS at 20 MHz and operates between 2.7-5.5 volts.

Datasheet: download

ATtiny85 pinout

  • Pin 1 - reset
  • Pin 2 - digital pin 3 / analog pin 3
  • Pin 3 - digital pin 4 / analog pin 2
  • Pin 4 - gnd
  • Pin 5 - digital pin 0 (PWM)
  • Pin 6 - digital pin 1 (PWM)
  • Pin 7 - digital pin 3 (PWM)
  • Pin 8 - Vcc (2.7~5.5V)

Step 3: Arduino UNO As an ISP

Here's the "Arduino ISP" code, embedded using Codebender!

Try downloading the Codebender plugin and clicking on the "Run on Arduino" button to program your Arduino board with this sketch. And that's it, you've programmed your Arduino with the ISP program!

Now disconnect the Arduino usb cable from your computer and proceed to next step.

Step 4: Connecting the Arduino Uno With the ATtiny85

Picture of Connecting the Arduino Uno With the ATtiny85

The connections are pretty easy, see the above image with the breadboard circuit schematic.

Tip: The dot in the corner of the ATtiny shows the first pin.

  • Pin 1 to Arduino pin 10
  • Pin 2 -
  • Pin 3 -
  • Pin 4 to Arduino GND pin
  • Pin 5 to Arduino pin 11
  • Pin 6 to Arduino pin 12
  • Pin 7 to Arduino pin 13
  • Pin 8 to Arduino 5V pin

Connect a 10uF electrolytic capacitor between Arduino uno reset pin and ground.

Tip: The stripe on one side of the capacitor shows the negative pin and should connected with ground.

We will use the capacitor because it prevents the Arduino UNO from resetting, so we are sure that the Codebender (or Arduino IDE) talks to the ArduinoISP, and not with the bootloader, during the upload of sketches.

You can now connect again the Arduino uno to your computer and proceed to next step!

Step 5: Program the ATtiny85 With Codebender

Picture of Program the ATtiny85 With Codebender

We will use Codebender - online Arduino IDE - to program the ATtiny85 micro controller. Click here to connect with your Codebender account.


New to Codebender?

Codebender is an online Arduino IDE, and free of use! Why Codebender? You can write and program your Arduino boards from your browser and the best part is that you can store all of your sketches online! So there accessible from everywhere! Also you can share them with your friends and social networks.

With 517 builtin libraries, codebender offers the most comprehensive list of Arduino libraries in the world, and you can simply include them in your projects to use them.

Click here to make your new Codebender account for free!


Make a new sketch

We will make a new sketch for the ATtiny85 that will turn on an LED. We will connect the LED with a 220 Ohm resistor to digital pin 3 (pin 2 of ATtiny85).


Click on the "Create new sketch" button.

In the void loop() we will define the D3 as an outup: pinMode(3, OUTPUT); and we will turn on an LED with: digitalWrite(3, HIGH);.

For the next steps see the image above:

  • Select port (mine is COM3)
  • Select from boards menu the ATtiny85 with 8MHz internal osc
  • Click on advanced options button (gear icon on the right)
  • Select "Arduino as ISP"
  • Press the "Run on Arduino" button

That's it, you've programmed the ATtiny85 with this sketch!

Supported Arduino Commands:

  • pinMode()
  • digitalWrite()
  • digitalRead()
  • analogRead()
  • analogWrite()
  • shiftOut()
  • pulseIn()
  • millis()
  • micros()
  • delay()
  • delayMicroseconds()
  • SoftwareSerial()

Step 6: Well Done

Picture of Well Done

Now you can remove the "programming" wires from the Arduino uno board.

You will only need power cables from 5V and GND. You can also use a rechargeable battery 3.7V or an external power source (max 5V)

You have successfully completed one more "How to" tutorial and you learned how to program the ATtiny85 micro-controller with the Arduino uno board!

I hope you liked this, let me know in the comments.

There will be more of them, so make sure to click Follow button!

Find more useful Arduino Tutorials here.

Comments

afmarks (author)2016-03-25

I flashed Blink to an ATTiny85, but it appears to be running on a 1MHz clock, even though I selected "8MHz internal". What am I doing wrong???

ShaunH53 (author)afmarks2017-10-28

you’ll have to reburn the bootloader at 8mhz using the Arduino IDE. I had to do this earlier today so I know it can be done.

ShaunH53 made it! (author)2017-10-28

I spent a bit of time today messing about with breadboards so I made an arduino shield to program the AtTiny85. It was my first attempt at this and I wanted to use it to run adafruit neopixels, which it does nicely off a rechargeable lipo, thanks for a useful tutorial.

DavidB565 (author)2016-02-28

who has a spare arduino board please give me philippine

Tanmay Deuskar (author)2015-11-22

Hello,

if I want to use a different pin as an output will I have to wire it differently wile programming it?

Thnx

L.H made it! (author)2015-10-22

Arduino ISP can be made using Arduino Micro. But, it is necessary to change line :

#define RESET ss

to

#define RESET 11

in the code.

and connect ATtiny85 to this pins of Micro:

Tiny 1 - D11
Tiny 5 - MOSI
Tiny 6 - MISO
Tiny 7 - SCK

diy_bloke (author)2015-10-14

Well done. Just an well meant advise to anybody planning to program a few attiny's: make a small shield that sticks in your arduino. wiring up a breadboard become really tedious after a while :-)
As far as codebender goes: Really handy. No more fiddling with having the right boards installed. I do almost all my programming in codebender now

Cancerkazoo (author)diy_bloke2015-10-18

A ZIF socket on a breadboard would be perfect.

diy_bloke (author)Cancerkazoo2015-10-20

..true, but on a breadboard one is bound to use those stick in wires again and that is exactly what i wanted to get away from. With 2x4 legs the Attiny is not really hard to remove from its socket

Cancerkazoo (author)diy_bloke2015-10-20

I was a little unclear. I meant a ZIF socket on one of those $0.50 pc solder breadboards. I'm not sure that they are big enough to make a shield with, but there are different sizes. By the time you solder everything up though, you may be close to a $7 shield anyway.

diy_bloke (author)Cancerkazoo2015-10-20

have never seen a solder up breadboard so I am not sure about that. smallest zif I have seen is 14 pins and cost about 2 euro's. Danger with a bigger zif is misplacement. The regular 8 pin sockets are really very easy. screwdriver under the chip and they pop out fast easy and unharmed.
The shield I put together probably cost me around 1 euro: pins, socket, capacitor.
resistors and leds added but not really necessary

https://www.instructables.com/id/Supersimple-Attiny...

About This Instructable

20,299views

394favorites

License:

Bio: Arduino Tutorials by Codebender.cc Team
More by codebender_cc:How to use a magnetic door switch / sensor with ArduinoHow to Measure LUX With ArduinoHow to Control an RGB LED Strip - Arduino Tutorial
Add instructable to: