Not every project needs a full-size Arduino Uno. Sometimes you just need a few GPIO pins, minimal power consumption, and something small enough to hide inside a wearable or product enclosure. That’s exactly where the ATtiny85 excels. This tutorial on ATtiny85 projects covers everything from programming the chip using your Arduino as an ISP to real-world projects you can build and deploy today. With 5 usable I/O pins, an 8-bit AVR core, and a price point under ₹50, the ATtiny85 is one of the most cost-effective microcontrollers available to Indian makers.
Table of Contents
- What Is the ATtiny85?
- ATtiny85 Pinout and Pin Functions
- Programming ATtiny85 with Arduino as ISP
- Installing ATtiny Core: Board Support for Arduino IDE
- Project 1: LED Candle Flicker Effect
- Project 2: Temperature Monitor with DS18B20
- Project 3: Capacitive Touch Sensor
- Limitations and When to Use a Full Arduino Instead
- Frequently Asked Questions
What Is the ATtiny85?
The ATtiny85 is a small, low-power, 8-bit AVR microcontroller made by Microchip (formerly Atmel). It’s part of the ATtiny family — a line of bare-minimum microcontrollers designed for applications where you need just enough computing power with the smallest possible footprint and the lowest possible power draw.
Here are the key specifications:
- Architecture: 8-bit AVR RISC
- Clock Speed: Up to 20 MHz (external crystal), 8 MHz (internal oscillator), or 1 MHz (default with clock prescaler)
- Flash Memory: 8 KB (program storage)
- SRAM: 512 bytes
- EEPROM: 512 bytes
- I/O Pins: 6 total (5 usable when using internal oscillator; 1 is RESET)
- ADC Inputs: 4 (10-bit)
- PWM Outputs: 3
- Interfaces: SPI, I2C (USI — Universal Serial Interface), one hardware UART via software
- Package: DIP-8 (breadboard-friendly), SOIC-8, TSSOP-8
- Operating Voltage: 1.8V to 5.5V
- Active Current: ~5 mA at 5V/16 MHz
- Sleep Current: As low as 0.1 μA in power-down mode
The DIP-8 package is perfect for hobbyists — 8 pins in a breadboard-friendly format. Pin 1 through 8 are clearly marked with the dot on the chip package indicating pin 1. The programming interface (ISP) uses pins 5, 6, 7 (MOSI, MISO, SCK) plus RESET and power.
ATtiny85 Pinout and Pin Functions
The ATtiny85 DIP-8 package has 8 pins total. Here’s what each pin does:
- Pin 1 – PB5 / RESET: This pin is the hardware reset. Can be repurposed as I/O with fuse bit changes (not recommended for beginners — it disables ISP programming)
- Pin 2 – PB3: Digital I/O, ADC3, can be used with analog reference
- Pin 3 – PB4: Digital I/O, ADC2
- Pin 4 – GND: Ground
- Pin 5 – PB0: Digital I/O, PWM (OC0A), SPI MOSI, I2C SDA
- Pin 6 – PB1: Digital I/O, PWM (OC0B), SPI MISO
- Pin 7 – PB2: Digital I/O, ADC1, SPI SCK, I2C SCL
- Pin 8 – VCC: Power supply (1.8V to 5.5V)
In Arduino-style pin numbering when using the ATtinyCore library: PB0=0, PB1=1, PB2=2, PB3=3, PB4=4. The analog pins for analogRead() are A0 (PB5), A1 (PB2), A2 (PB4), A3 (PB3).
Important note: The ATtiny85 does NOT have a hardware UART. If you need serial debugging, use SoftwareSerial or, better yet, use Digispark’s or SpenceKonde’s debug libraries that implement one-wire serial output on a single pin using bit-banging.
Programming ATtiny85 with Arduino as ISP
You don’t need a dedicated programmer to upload code to an ATtiny85. Your Arduino Uno can act as an In-System Programmer (ISP). Here’s exactly how to do it:
Step 1: Upload ArduinoISP Sketch to Your Uno
Open the Arduino IDE. Go to File → Examples → 11.ArduinoISP → ArduinoISP. Select your Uno board and port, then upload this sketch. This turns your Uno into a programmer.
Step 2: Wire the ATtiny85 to the Uno
Connect them as follows (add a 10µF capacitor between RESET and GND on the Uno to prevent auto-reset during programming):
- Uno Pin 13 → ATtiny85 Pin 7 (SCK)
- Uno Pin 12 → ATtiny85 Pin 6 (MISO)
- Uno Pin 11 → ATtiny85 Pin 5 (MOSI)
- Uno Pin 10 → ATtiny85 Pin 1 (RESET)
- Uno 5V → ATtiny85 Pin 8 (VCC)
- Uno GND → ATtiny85 Pin 4 (GND)
Step 3: Install ATtiny Board Support (see next section)
Step 4: Select ATtiny85 Board
In Tools → Board, select “ATtiny25/45/85”. In Tools → Processor, select “ATtiny85”. In Tools → Clock, select “8 MHz (internal)” for most projects. Set Tools → Programmer to “Arduino as ISP”.
Step 5: Burn Bootloader (Set Fuses)
Go to Tools → Burn Bootloader. This doesn’t actually install a bootloader (the ATtiny85 doesn’t use one) — it sets the fuse bits that configure the clock speed and other hardware settings. You only need to do this once when setting up a new chip.
Step 6: Upload Your Sketch
Write your sketch, then go to Sketch → Upload Using Programmer (NOT the regular Upload button). The sketch will compile and upload to the ATtiny85 via the Uno ISP.
Installing ATtiny Core: Board Support for Arduino IDE
To program the ATtiny85 in the Arduino IDE, you need to add the ATtiny board support package. The most popular and well-maintained one is SpenceKonde’s ATTinyCore.
Installation:
- Open Arduino IDE → File → Preferences
- In “Additional Boards Manager URLs”, add:
http://drazzy.com/package_drazzy.com_index.json - Click OK. Go to Tools → Board → Boards Manager
- Search for “ATTinyCore” and install it
- Under Tools → Board, you’ll now see “ATtiny25/45/85” and other ATtiny variants
ATTinyCore supports the full Arduino API for ATtiny chips including analogWrite(), analogRead(), Wire (I2C via USI), SPI, and SoftwareSerial. Not all features of larger Arduinos are available (no hardware UART, limited timers), but the core API is there.
Project 1: LED Candle Flicker Effect
This is the classic ATtiny85 starter project — a realistic LED candle that flickers like a real flame. It’s perfect for mood lighting, Halloween props, or decorative lighting. You just need an LED, a 220Ω resistor, and an ATtiny85.
The key to realistic flicker is pseudo-random PWM variation. Here’s the simplified concept:
#include <Arduino.h>
const int LED = 0; // PB0, Pin 5
void setup() {
pinMode(LED, OUTPUT);
}
void loop() {
int flicker = random(120, 255);
analogWrite(LED, flicker);
delay(random(20, 100));
// Occasional "gust" effect
if (random(100) < 5) {
analogWrite(LED, random(50, 100));
delay(random(50, 150));
}
}
The random function creates the natural irregularity that makes candle flicker believable. Power this from two AA batteries (3V) — the ATtiny85 runs happily at 3V with the internal 8 MHz oscillator. Total current draw: around 20mA including the LED. Runtime on AA batteries: several days of continuous operation.
Project 2: Temperature Monitor with DS18B20
A standalone temperature logger that wakes up every minute, reads the DS18B20 temperature sensor, and blinks an LED to signal whether it’s within the normal range. No display needed — perfect for inside enclosures or remote monitoring.
Circuit: DS18B20 data pin → ATtiny85 PB1, with a 4.7kΩ pull-up to VCC. LED on PB0 for status. The ATtiny85 spends 99% of its time in deep sleep (0.1µA), waking via the watchdog timer every 8 seconds. This project can run for months on two AA batteries.
The OneWire and DallasTemperature libraries work with ATtiny85 after installing ATTinyCore. The key is using the ATtiny85’s power-down sleep mode between readings to achieve ultra-low average current consumption — typically under 50µA when accounting for sleep/wake cycles.
Project 3: Capacitive Touch Sensor
The ATtiny85 can implement capacitive touch sensing through a technique called charge-time measurement. By toggling a pin and measuring how long it takes to charge through a human body’s capacitance, you can detect touch events. The CapacitiveSensor library works with ATtiny85.
Circuit: Two adjacent pads on a PCB or copper tape connected to two ATtiny85 pins. No additional components needed. Touch the sensor pad and the ATtiny85 detects the change in capacitance. This is how most budget touch-sensitive devices work internally.
Limitations and When to Use a Full Arduino Instead
The ATtiny85 is powerful for its size, but it has real limitations you need to understand before committing to it for a project:
When ATtiny85 is the right choice:
- Final product deployment where size and cost matter
- Battery-powered devices needing ultra-low sleep current
- Projects needing only 2-4 I/O pins
- High-volume production (low per-unit cost)
- Applications where a full Arduino feels over-engineered
When to stick with a full Arduino:
- You need more than 5 I/O pins
- Your project requires a display, SD card, Ethernet, or Wi-Fi
- You need hardware Serial for debugging or communication
- Library compatibility is important (many libraries don’t support ATtiny)
- You’re prototyping — prototype on Uno/Nano, then shrink to ATtiny85 for production
- You need more than 8KB of flash or 512 bytes of RAM
A common workflow: prototype your project on an Arduino Nano or Uno with plenty of pins and memory. Once the code is working, port the final version to an ATtiny85 for the production build. This gives you the best of both worlds — easy development and minimal production hardware.
Frequently Asked Questions
Can the ATtiny85 run Arduino code directly?
Yes, with the ATTinyCore board support package installed, most standard Arduino functions work on the ATtiny85 — including pinMode(), digitalWrite(), analogRead(), analogWrite(), delay(), and millis(). Hardware-specific functions like Serial.begin() don’t work directly since there’s no hardware UART, but SoftwareSerial is available.
How do I debug code on the ATtiny85 without Serial?
The most common approach is blinking LEDs to signal different states (error codes, variable ranges, etc.). Another option is using the TinyDebugSerial library which implements one-wire serial output using bit-banging. You can also temporarily replace the ATtiny85 with an Arduino Nano for debugging, then re-deploy to ATtiny85 once the logic is verified.
What is the ATtiny85 vs ATtiny84 difference?
The ATtiny84 is the 14-pin sibling of the ATtiny85. It has 12 I/O pins (vs 6), 8KB flash (same), and 512 bytes SRAM (same). It also comes in a DIP-14 package. Choose the ATtiny84 when you need more I/O pins but still want the tiny form factor. Both are programmed the same way using Arduino as ISP.
Can I use I2C with the ATtiny85?
Yes, through the USI (Universal Serial Interface) peripheral. The TinyWire library (available via ATTinyCore) provides I2C/Wire-compatible functions for the ATtiny85. You can communicate with I2C sensors, displays, and other devices. The I2C pins are PB2 (SCL) and PB0 (SDA).
How long does an ATtiny85 project last on batteries?
In deep sleep mode, the ATtiny85 draws as little as 0.1µA. Even with periodic wake-ups every 8 seconds for sensor reading (drawing ~5mA for 50ms), the average current is negligible. A CR2032 coin cell (225mAh) can power an ATtiny85 sensor node for several years. Two AA batteries can power it indefinitely for practical purposes.
Ready to start your ATtiny85 project?
Find all the Arduino boards and components you need at Zbotic.in — India’s trusted electronics store for makers and engineers.
Add comment