Overview

The ATtiny85 is a famous low-power 8-bit AVR RISC microcontroller IC manufactured by Microchip Technology (Atmel). Housed in an ultra-compact 8-pin DIP package (DIP-8), it is the favored MCU for miniature DIY electronics projects, wearable devices, keychains, and Digispark USB development boards.

Despite its tiny footprint, the ATtiny85 features 8 KB8\text{ KB} of Flash memory, 512 Bytes512\text{ Bytes} of SRAM, 512 Bytes512\text{ Bytes} of EEPROM, a 4-channel 10-bit ADC, high-speed 64MHz PWM timer, and an internal 8 MHz16 MHz8\text{ MHz} \dots 16\text{ MHz} calibrated RC oscillator, allowing operation without any external crystal or supporting components.

Quick reference

CPU Architecture8-bit AVR RISC
Package8-pin DIP (ATtiny85-20PU) / 8-pin SOIC / Digispark Module
Max Clock Frequency20 MHz20\text{ MHz} (Internal 8 MHz8\text{ MHz} or 16 MHz16\text{ MHz} PLL default)
Memory Breakdown8 KB8\text{ KB} Flash, 512 B512\text{ B} SRAM, 512 B512\text{ B} EEPROM
Operating Voltage (VCC)2.7 V to 5.5 V DC (1.8 V for ATtiny85V)
GPIO Lines6 Pins (PB0 to PB5, including PB5 Reset pin)
PWM & Timers2 Timers, 4 PWM channels (High-speed 64MHz PLL timer)
Analog Input4-channel 10-bit ADC (ADC0 to ADC3)
Serial Hardware InterfaceUSI (Universal Serial Interface for I2CI^2C & SPI)

Pinout (DIP-8 Package)

text
                       ┌───┴───┐
     (PCINT5/RESET) PB5 ─┤ 1   8 ├─ VCC (+2.7V to +5.5V)
    (PCINT3/ADC3)   PB3 ─┤ 2   7 ├─ PB2 (SCK/SCL/ADC1)
    (PCINT4/ADC2)   PB4 ─┤ 3   6 ├─ PB1 (MISO/DO/PWM1)
                    GND ─┤ 4   5 ├─ PB0 (MOSI/SDA/PWM0)
                       └───────┘
PinNamePrimary FunctionsArduino Pin Mapping
1PB5/RESET, ADC3, PCINT5Reset Pin (Pin 5)
2PB3ADC3, PCINT3, XTAL1Physical Pin 2 (Analog A3)
3PB4ADC2, PCINT4, XTAL2, PWMPhysical Pin 3 (Analog A2, PWM)
4GNDGround Reference (0V)Ground
5PB0MOSI, SDA, AREF, PWM0Digital Pin 0 (PWM / I2CI^2C SDA)
6PB1MISO, DO, PWM1Digital Pin 1 (PWM / SPI MISO)
7PB2SCK, SCL, ADC1Digital Pin 2 (Analog A1 / I2CI^2C SCL)
8VCCPositive Supply Input (+2.7V to +5.5V DC)Power Rail

Specifications

ParameterSymbolMinTypMaxUnitConditions
Supply VoltageVCCV_{CC}2.75.05.5VStandard ATtiny85-20PU
Active Supply CurrentICCI_{CC}300800µAVCC=3.0V,fCLK=1MHzV_{CC} = 3.0\text{V}, f_{CLK} = 1\text{MHz}
Power-down CurrentIpdI_{pd}0.11.0µAVCC=3.0V,TA=25CV_{CC} = 3.0\text{V}, T_A = 25^\circ\text{C}
Internal Calibrated ClockfRCf_{RC}7.38.08.7MHzInternal RC oscillator
GPIO Output Sink/SourceIIOI_{IO}-40+40mAAbsolute max per pin

Minimal Circuit (Internal 8MHz Clock - Zero External Parts Needed)

text
        +5V DC Power Supply

        [Pin 8: VCC] ─── [ 0.1µF Capacitor ] ─── GND

        [Pin 1: PB5/RESET] ─── [ 10kΩ Resistor ] ─── +5V

        [Pin 6: PB1] ─── [ 220Ω Resistor ] ─── (LED) ─── GND

Flashing ATtiny85 using Arduino Uno as ISP

  1. Open Arduino IDE \to Examples \to 11.ArduinoISP \to Upload to Arduino Uno.
  2. Install ATTinyCore board package in Arduino IDE.
  3. Select Board: ATtiny25/45/85, Processor: ATtiny85, Clock: Internal 8 MHz.
Arduino Uno (ISP Programmer)ATtiny85 DIP Pin
5VPin 8 (VCC)
GNDPin 4 (GND)
Digital 10Pin 1 (PB5 / RESET)
Digital 11Pin 5 (PB0 / MOSI)
Digital 12Pin 6 (PB1 / MISO)
Digital 13Pin 7 (PB2 / SCK)
cpp
// On ATtiny85, PB1 corresponds to Arduino Pin 1
const int ledPin = 1; 

void setup() {
  pinMode(ledPin, OUTPUT);
}

void loop() {
  digitalWrite(ledPin, HIGH);
  delay(1000);
  digitalWrite(ledPin, LOW);
  delay(1000);
}

Common mistakes

  • Disabling the RESET pin (RSTDISBL fuse): Reprogramming PB5 as a standard GPIO pin via the RSTDISBL fuse permanently disables serial ISP programming. High-Voltage Serial Programming (HVSP) is required to recover the chip.
  • Forgetting that PB0 and PB1 are used by the Digispark USB bootloader: On Digispark boards, PB3 and PB4 are tied to USB D+/DD+/D- pull-up lines.

Notes

  • ATtiny85 Family: ATtiny25 (2KB2\text{KB} Flash), ATtiny45 (4KB4\text{KB} Flash), ATtiny85 (8KB8\text{KB} Flash).

Assets & downloads