The DIY ATtiny programmer described here shows you how to program a
lot of chips in the ATtiny range. The example shown here uses the
ATtiny85 as an example chip with the Arduino Uno as the ATtiny
programmer (so it is an ATtiny85 programmer).
In fact the setup is very easy - all you do is connect the
SPI signals from the programmer to the SPI signals on the target chip.
Note: You can use many other Arduino boards as the programmer.
Note that while this setup is fairly easy it has extra steps compared
to using the Digispark ATtiny USB interface. If you are not worried
about the program size - yet! (the main reason for using this process) -
then using the Digispark board is a good idea.
An Interesting Question
How many external components do you need to operate an Arduino Sketch
in an ATtiny85? If you think about an Uno or Nano (or any other Arduino
board) you could come up with about 10 components but what is the
Q: What are the minimum number of components required to run an Arduino Sketch in an ATtiny85?
(click to find out)
Amazingly the answer is 3 (if you include the power supply) -
You only need the ATtiny85, a decoupling capacitor and a power source e.g.LiPoly battery. All the other
components on Arduino boards are convenience components e.g a USB
interface, external crystal clock, power supply conditioning etc.
You should have at least one power supply decoupling capacitor to
eliminate switching noise. If you program the ATtiny85 using an AVRISP
as described here then you don't need the USB interface chip (required
on all Arduino boards).
Obviously you will need more external components to create the useful
circuit but by using an ATtiny85 you can create the smallest possible
In normal use the Arduino IDE
communicates with an Arduino board, pre-programmed with a bootloader.
This is a small program that communicates over the serial link,
allowing you to easily upload programs using the Arduino IDE. This is
the reason that you don't need an ISP chip programmer for Arduino projects.
There are several reasons using an ISP programmer; you might need to:
Save some space by not using a bootloader.
Re-program the bootloader (or program the bootloader into a new chip).
Use the chip with a slower (internal) clock.
One problem is that the bootloader uses up some of the Flash memory in the
chip; memory which you can't use for your own program. You may just
need that extra 2k of
space and decide not to use a bootloader!
Why use an ISP ATtiny programmer?
Using an ISP programmer allows you to upload
a standard program directly to the target chip without requiring the
target chip to be pre-programmmed i.e. you don't need a bootloader to execute Arduino sketches.
The disadvantage is that you have to connect up the SPI signals (MOSI
MISO etc.) to the target chip. This usually means removing the chip
from the project board and putting it into the programmer board (unless
the SPI pins are routed to a connector, which is more likely for higher
Dedicated ISP or Arduino ISP?
You can buy a dedicated AVR ISP programmer that plugs into a USB port providing the required ISP signals.
Alternatively you can use the Arduino
IDE along with a standard Arduino board; using the Arduino board itself
as your ISP programmer - this turns your Arduino into an AVRISP.
If you are on a budget then the Arduino programmer is the one you want.
ATtiny Programmer library
Install Spence Konde library
You need to add an entry for the boards manager. Select:
Menu > File > Preferences
...and paste the following:
...into the text field labelled 'Additional Boards Manager URLs'.
If you have problems make sure you have Arduino IDE 1.8.9 or later.
Now open the boards manager and select ATtinyCore by Spence Konde:
Menu > Tools > Board > Boards Manager
Chip list for Spence Konde library
Here's a list of the chips that can be programmed using the Spence Konde library:
ATtiny24/44/84(a) (No bootloader)
ATtiny84(a) (Micronucleus / California STEAM)
ATtiny24/45/84 (No bootloader)
ATtiny85 (Micronucleus / DigiSpark)
ATtiny44/88 (No bootloader)
ATtiny88 (Micronucleus, MH-ET t88 w/16MHz CLOCK)
ATtiny87/167 (No bootloader)
ATtiny167 (Micronucleus / DigiSpark Pro)
ATtiny441/841 (No bootloader)
ATtiny841 (Micronucleus / Wattuino)
ATtiny43 (No bootloader)
ATtiny828 (No bootloader)
ATtiny1634 (No bootloader)
ATtiny2313(a)/4313 (No bootloader)
You can see that you do have the option of using a
specific bootloader but check how much memory it takes up; its a trade
off between convenience and the amount of memory used.
Here's a few points of interest on some of these chips:
Here you program the Arduino Uno with a Sketch that allows it to be an ATtiny programmer (an ISP - In System Programmer).
Select the Arduino ISP from the example programs in the IDE:
Menu > File > Examples > 11.ArduinoISP > ArduinoISP
ATtiny programmer: From the Tools Menu set-up three options:
Board: "Arduino/Genuino Uno". This is the programmer board in use.
Port : COMnn. (Arduino/Genuino Uno); The port for your Arduino Uno.
Programmer : "Arduino as ISP".
They should match the screen shot below - except for the port number which will be different for your system.
Program the sketch into the Arduino Uno.
Menu > Sketch > Upload
Note: Pins are on PORTB (it only has PORTB and no PORTA!) so you can use code such as:
... to set all pins on PORTB high.
As with all Arduino boards pins are related to logical port pins and
not physical chip pin numbers so check the diagram for the correct 'pin'
when coding for Arduino.
AVRISP Connection diagram
This diagram shows you how to wire up the Arduino uno as an ATtiny
programmer. Simply connect MISO, MOSI, SCK, 5V and GND to the chip.
Additionally connect pin 10 to the reset pin on the chip.
Arduino Uno pin
ATtiny85 [chip] pin
13 - SCK
7 - SCK - White
12 - MISO
6 - MISO - Purple
11 - MOSI
5 - MOSI - Blue
10 - RESET
1 - RESET - Yellow
GND - Green
VCC - Red
For testing (optionally) add 1k resistor to pin 3, and LED anode to
the resistor. The flat side is the cathode which connects to GND.
Optional ATtiny Programmer Status LEDs
You can also add LEDs (and resistors) to the following Arduino Uno pins to show programmer status:
Heartbeat - programmer is operational.
Error - something went wrong.
Programming - communicating with target.
IDE Set-up for the ATtiny85
Now choose the no-bootloader option for ATtiny85 as follows:
Menu > Tools > Board > ATtinyCore > ATtiny25/45/85 (No bootloader):
Note: Leave the other settings at default values i.e. 8MHz (Internal) clock etc.
So this shows the setup for an ATtiny85 programmer.
Programming the ATtiny85
Do this FIRST - Clock Setting and BOD
Perform a 'Burn Bootloader' before programming your Sketch but after programming the Arduino Uno as an AVRISP.
Menu > Tools > 'Burn Bootloader'
TIP: DO THIS FIRST: Menu > Tools > 'Burn Bootloader'
Since you have setup the board as an ATtiny85, burning the bootloader
(can) burn a bootloader into the ATtiny85 (Not the Arduino Uno). For
the setup here, where no bootloader is selected, it is not bunt in -
however the other settings must be updated.
Clicking burn bootloader, in this case, will program the clock setting fuses or BOD
If you want to:
Change the internal clock used,
Change the BOD (Brown Out
Set clocks for the first time,
Set BOD for the first time.
...then you must hit
Menu > Tools > 'Burn Bootloader'
The action of programming the bootloader sets the ATtiny85 fuses that
allow a clock change. This is the reason that the text is written into
the Clock source menu item:
Menu > Tools > Clock Source (Only Set on bootload) "8Mhz (internal)"
Warning: Click Burn Bootloader when changing clocks or BOD.
When you re-program the ATtiny85 with your Sketch (without a
bootloader selected), the fuses are left as they were - i.e. correct for the
selected clock rate.
Note: Burning the Bootloader erases the original Sketch!
If you had a program in the Attiny85, after burning the bootloader you need to reload it; burning the bootloader erases memory.
LED Flash program for ATtiny85
The standard blink example uses LED_BUILTIN which is pin 6 on the
ATtiny85 and it is connected to MOSI above. If you removed the chip and
then attached an LED to pin 6 via 1k to ground it would work on another
solder-less breadboard. However to test it in the circuit above you need
to use pin 4 (here set by definition TEST_LED) and not LED_BUILTIN.
The text LED_BUILTIN was changed to TEST_LED to use allow you to use any LED pin:
#define TEST_LED 4
// The setup function runs once on reset or powering the board.
// initialize digital pin TEST_LED as an output.
// the loop function runs over and over again forever
digitalWrite(TEST_LED,HIGH);// turn the LED on.
// PORTB= 0xff;
digitalWrite(TEST_LED,LOW);// turn the LED off.
// PORTB= 0x00;
Note: The pin refers to PB4 not the physical pin (PB4 is on chip pin 3).
Programming the ATtiny85 Sketch
To program the ATtiny85 with the standard Arduino code, using the
ATtiny85 programmer, just hit the programming symbol (right arrow as
usual) or use the menu; it is exactly the same as normal Arduino IDE
Menu > Sketch > Upload
The reason this works is that the IDE bypasses the normal serial
interface and uses the Arduino Uno as an ISP programmer (because of the
setup you did previously).
Sketch uses 700 bytes (11%) of program storage space. Maximum is 6012 bytes. Global variables use 9 bytes of dynamic memory.
Here the maximum space is reduced by 2180 Bytes (more than 1/4 of the total available) - this loss is due entirely to the bootloader code.
These are the same chip but the Digispark system uses a software
bit-banged USB interface (bootloader) that is very clever (and convenient) but does
require a lot of Flash memory.
For the ATtiny85 you can save more than 1/4 of the total available Flash
memory space. For some programs this will be essential as having only
6k is small enough as it is, but having a boost of 2k could allow the project to
An ATtiny programmer also allows you to change the clock frequency which can be important in low power operation.