raw electronics

For numerous low-power applications that require only a few inputs and outputs, the ATtiny85 is an excellent choice. This versatile microcontroller offers digital pins, analog pins, PWM outputs, and many more, making it well-suited for tasks where an Arduino might be too costly or energy-consuming.

Materials Needed

ATTiny85 Pinout

The most important pins of the ATTiny85 are the analog pins, digital pins, SPI pins and I2C pins.

ATtiny85 Pinout

Step 1: Set Up the Arduino Uno as an ISP

  1. Connect the Arduino Uno to your computer using a USB cable.

  2. Open the Arduino IDE on your computer.

  3. Load the ArduinoISP sketch:

    • Go to File > Examples > 11. ArduinoISP > ArduinoISP.
    • Upload this sketch to your Arduino Uno.
Configure Arduino as ISP

Step 2: Wire the ATtiny85 to the Arduino Uno

ATtiny85 on a breadboard connected to Arduino
  1. Disconnect the Arduino Uno from your computer to prevent any power issues during wiring.
  2. Put the ATtiny85 to the breadboard.
  3. Connect the Arduino Uno to the ATtiny85 as follows:
    • Arduino Uno Pin 10 to ATtiny85 Pin 1 (Reset)
    • Arduino Uno Pin 11 to ATtiny85 Pin 5 (MOSI)
    • Arduino Uno Pin 12 to ATtiny85 Pin 6 (MISO)
    • Arduino Uno Pin 13 to ATtiny85 Pin 7 (SCK)
    • Arduino Uno 5V to ATtiny85 Pin 8 (Vcc)
    • Arduino Uno GND to ATtiny85 Pin 4 (GND)
  4. Add a 10μF capacitor between RESET and GND on the Arduino Uno to prevent it from resetting during the upload.

Step 3: Configure the Arduino IDE for ATtiny85

  1. Add ATtiny support to the Arduino IDE:

Add ATtiny85 board to Arduino
  1. Open the Boards Manager:
    • Go to Tools > Board > Boards Manager.
    • Search for "attiny" and install the "Attiny by David A. Mellis".
Show ATtiny85 in board manager of Arduino IDE
  1. Select the ATtiny85 board:

    • Go to Tools > Board and select ATtiny25/45/85.
  2. Select the ATtiny85 processor:

    • Go to Tools > Processor and select ATtiny85.
  3. Select the clock speed:

    • Go to Tools > Clock and select Internal 8 MHz.

Step 4: Burn the Bootloader

Burn the bootloader to configure the ATtiny85 fuses:

Burn the ATtiny85 bootloader using Arduino

During the bootloader burning process, you will observe flashing LEDs on the Arduino Uno. This process will take a few seconds. Once the bootloader has been successfully burned, the LEDs on the Arduino Uno will stop flashing, and a confirmation message will appear in the Arduino IDE.

Step 5: Upload Your Sketch to the ATtiny85

  1. Write your sketch as you would for any other Arduino board.
  2. Select the correct programmer:
    • Go to Tools > Programmer and make sure Arduino as ISP is selected.
    • Upload your sketch: Use the Upload Using Programmer option by going to Sketch > Upload Using Programmer.

Example Blink Sketch

To operate the ATtiny85, connect VCC and GND as the minimum requirements. For a basic LED blink program, use digital pin 0 to control the LED, and include a 47-ohm resistor in series with the LED to limit the current at 3V. The operating voltage range for the ATtiny85 is 2.7V to 5.5V.

Run ATtiny85 with a battery in a simple blink sketch

The following code snippet demonstrates a basic LED blinking program for the ATtiny85. Upload the

void setup() {
  pinMode(0, OUTPUT); // Use pin 0 (physical pin 5 on ATtiny85)
}

void loop() {
  digitalWrite(0, HIGH); // Turn the LED on
  delay(1000); // Wait for a second
  digitalWrite(0, LOW); // Turn the LED off
  delay(1000); // Wait for a second
}