Project tutorial

Programming ATtiny85 with Arduino Uno © GPL3+

Step by step on how to program a ATtiny85 microcontroller with Arduino Uno development board.

  • 106,822 views
  • 61 comments
  • 125 respects

Components and supplies

About this project

I am working on a project which requires reading multiple sensor data on different locations. These require only few PWM pins so using multiple Arduino Uno would be expensive and unnecessary. So I decided to use ATtiny85 microcontroller in place of Arduino Uno development boards. ATtiny85 is a cheap and powerful alternate when u don't need too many PWM pins. Since ATtiny85 is just a microcontroller we need a Arduino Uno to program it. In this project I will explain how to do it. Below is the pin configuration of ATtiny85 and the datasheet can be found here http://www.atmel.com/images/atmel-2586-avr-8-bit-microcontroller-attiny25-attiny45-attiny85_datasheet.pdf.

Configuring Arduino Uno as a ISP (In-System Programming)

To program the ATtiny85 we need to first set Arduino Uno in ISP mode. Connect your Arduino Uno to the PC. Open Arduino IDE and open the ArduinoISP example file (File -> Examples -> ArduinoISP) and upload it.

Adding ATtiny85 Support to Arduino IDE

By default Arduino IDE doesn't support ATtiny85 so we should add ATtiny boards to Arduino IDE. Open File -> Preferences and in the Additional Boards Manager URLs give this url https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json.

After this is done open Tools -> Board -> Board Manager

After opening Board Manager scroll down the list where it says "attiny by Davis A. Mellis". Click on that and install it.

After installing now you would be able to see a new entry in the Board menu

Connecting ATtiny85 with Arduino Uno

Now with all the above things ready we will start programming the attiny85. Connect the arduino uno to attiny85 using breadboard as below.

Arduino Uno – ATtiny85

  • 5V – Vcc
  • Gnd – Gnd
  • Pin 13 – Pin 2
  • Pin 12 – Pin 1
  • Pin 11 – Pin 0
  • Pin 10 – Reset

Add a 10uF capacitor between RESET and GND in arduino. This is to avoid arduino from being auto reset when we upload the program to attiny85. If you are using a electrolytic capacitor make sure the anode goes in GND of uno.

Uploading program to ATtiny85

Now back to Arduino IDE. Select ATtiny under Tools -> Board. Then select ATtiny85 under Tools -> Processor. And select 8 MHz (internal) under Tools -> Clock.

Then make sure Arduino as ISP is selected under Tools -> Programmer

By default the ATtiny85 runs at 1MHz. To make it to run at 8MHz select Tools -> Burn Bootloader. 

You will get the above message if burning bootloader was successful.

Now open the Blink example from arduino examples and change the pin number from 13 to 0 and upload.

You can see the above message if everything was successful. Now we have upload the blink program to ATtiny85 and now lets test it out.

Now its time to test. Remove all connections from Arduino and take a power source. Here I will use a button cell to power ATtiny85. 

There it is the blink program running on a ATtiny85 with just a battery cell to power it. You can do many projects with low cost, low power and low space. Only your imagination is the limit here and the number of PWM pins of course.

Making it into a Shield

I converted the above circuit to a shield compatible with Arduino Uno.

(Note: Being a software developer this is my first ever project on electronics. Please give in your suggestions to help me do more.)

Schematics

Programming ATtiny85 with Arduino Uno - Breadboard
Programming%20attiny85%20with%20arduino%20uno bb
Testing ATtiny85 Blink
Testing%20attiny85%20blink bb

Code

Blink ProgramC/C++
/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.

  Most Arduinos have an on-board LED you can control. On the Uno and
  Leonardo, it is attached to digital pin 13. If you're unsure what
  pin the on-board LED is connected to on your Arduino model, check
  the documentation at http://arduino.cc

  This example code is in the public domain.

  modified 8 May 2014
  by Scott Fitzgerald
 */


// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin 13 as an output.
  pinMode(0, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(0, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);              // wait for a second
  digitalWrite(0, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);              // wait for a second
}

Comments

Similar projects you might like

Windows PC Lock/Unlock Using RFID

Project tutorial by Prasanth K S

  • 5,788 views
  • 6 comments
  • 26 respects

Multitasking FreeRTOS for Arduino

Project tutorial by Du Phạm

  • 137 views
  • 0 comments
  • 2 respects

Arduino Keyboard

Project in progress by Gabriele Scordamaglia

  • 117 views
  • 0 comments
  • 2 respects

Lie Detector

Project tutorial by Adaline Baskaran

  • 4,372 views
  • 3 comments
  • 18 respects

Makers (Cubecon) #1 Infrared Transmit & Infrared Receive

Project in progress by Alpha

  • 44 views
  • 0 comments
  • 2 respects
Add projectSign up / Login