Simvik

ATtiny85 pinout

The ATtiny85 (ATtiny85) pinout: what each pin does, from GPIO, analog inputs and PWM to UART, I2C and SPI, with the notes that catch people out.

The board

  • Microcontroller: ATtiny85, 8-bit AVR
  • Clock: 8 MHz (internal oscillator)
  • Flash: 8 KB
  • SRAM / EEPROM: 512 bytes / 512 bytes
  • Logic level: 5 V
  • I/O pins: 6 (PB0–PB5), 3 with PWM; PB5 is RESET
  • Analog inputs: 4 (A0–A3), 10-bit: 0–1023
  • Serial: In software: TX on PB0, RX on PB1
  • I2C and SPI: Through the USI: SDA PB0, SCL PB2; DI PB0, DO PB1, USCK PB2
  • External interrupts: PB2 (INT0); a pin-change interrupt on every pin
  • On-board LED: PB1 (LED_BUILTIN)

Pins

PinFunctionsNotes
PB00, PB0, ~PWM, OC0A, SDA, DI, TXanalogWrite() PWM from Timer0 (OC0A). The USI's data input (DI) for SPI, and SDA for I2C. Serial transmit: the core bit-bangs Serial here, as the chip has no USART.
PB11, PB1, ~PWM, OC1A, DO, RX, LEDanalogWrite() PWM from Timer1 (OC1A), about 490 Hz at 8 MHz. The USI's data output (DO): MOSI when the ATtiny is the SPI controller. Serial receive (software). Drives the on-board LED (LED_BUILTIN).
PB22, PB2, A1, INT0, SCL, USCKAnalog input: analogRead(A1). External interrupt INT0: attachInterrupt(0, handler, mode). The USI's clock: SCK for SPI, SCL for I2C.
PB33, PB3, A3Analog input: analogRead(A3).
PB44, PB4, A2, ~PWM, OC1BAnalog input: analogRead(A2). analogWrite() PWM from Timer1 (OC1B).
PB55, PB5, A0, RESETAnalog input: analogRead(A0). Also the chip's RESET: it only becomes an I/O pin when the RSTDISBL fuse is set, after which the chip can no longer be programmed over ISP.
GNDGNDGround (0 V).
GNDGNDGround (0 V).
VCC5VThe 5 V supply.
VCC5VThe 5 V supply.
VINVINUnregulated supply input, 7–12 V recommended. The on-board regulator makes 5 V from it.

Good to know

  • Pins are numbered by their port bit: digitalWrite(3, HIGH) drives PB3, and PORTB |= (1 << PB3) does the same without digitalWrite().
  • There is no USART, SPI or TWI peripheral: Serial is bit-banged on PB0 and PB1, and SPI and I2C libraries for the ATtiny use the USI.
  • Timer0 runs millis() and delay(); Timer1 does the PWM on PB1 and PB4.