Introduction: How to Program an ATtiny 85 Digispark
So, why another 'How to' about the ATtiny 85?
Mainly to clarify key steps that could help avoid the problems being experienced by so many, with errors like this:
"avrdude: stk500_getsync(): not in sync: resp=0x00 "
"avrdude: usbdev_open(): did not find any USB device "usb".
These instructions relate to the Digispark kickstarter, which is an Attiny85 USB Development Board for Arduino.(See photo).
I decided to get it with the intention of building a Fridge Door alert and expected a board would be better than just the chip. However, most tutorials just refer to the raw chip using pin numbers based around DIP (dual inline package) or relevant sockets. This was confusing because the Digispark board just has terminal numbers and it was hard to confirm which pin on the chip they were connected to. The next step will make this clear.
Step 1: Pin Designations
Finally after much searching I realised that the same physical pin can have different designations in the Arduino IDE (Integrated Development Environment).
Physical pins on Microcontrollers are numbered anticlockwise starting at the notch or dot on the back of the chip. Then, for example, physical pin 7 on the ATtiny85 is designated as digital 2 or Analog 1.
Step 2: Open Source Arduino IDE Setup
.
It is now assumed that the Open Source Arduino IDE has been downloaded and installed along with the ATtiny 85 board manager files.
If not, it is all detailed here: https://github.com/damellis/attiny/zipball/Arduino1
Step 3: Setup the Arduino As a Programmer
The Arduino Uno first needs to be setup as a Programmer or ISP (In System Programmer).
Select "Arduino Uno/Genuino" as the board .
Verify(Compile) & Upload the Sketch "ArduinoISP", found under Examples.
It should complete successfully with message Done Uploading.
This will confirm that correct Port is being used and communication between PC and theArduino Uno is working.
Step 4: Connect the Arduino Uno to the ATtiny 85 Digispark.
Also, a 10uF capacitor from Reset to GND on the Arduino Uno.
IMPORTANT: This prevents an auto reset when uploading the program to the ATtiny85.
However, an error will occur if it is connected in the previous Step, when Uploading the "ArduinoISP' Sketch.
It should only be connected in this step when using "Arduino as ISP" to program the ATtiny85.
Step 5: Burn Bootloader Onto ATtiny85.
To do this the Arduino must be setup as In System Programmer.
From Tools Menu,
Change Programmer to "Arduino as ISP"
From Tools, Board Select "ATtiny85" as the Board to be Programmed:
Recheck that the correct ATtiny is selected, otherwise there will be errors.
From the IDE Tools, Menu, Clock. Select: 8MHz Clock speed.
Burn Bootloader.
The IDE should confirm with 'Done burning bootloader'
Step 6: Upload a Sketch Program
This can be confirmed by hooking up LED tp pin P0 and Uploading Blink from examples list.
Note: Change pin number from 13 to 0. It appears in 3 places. Then, compile and upload.
Step 7: Test to Confirm
Hook up an LED to terminal 0 and power up the ATtiny85 via the mini USB or a battery.
Step 8: Check Programmer Heartbeat
Instead of blindly following steps, it helps in troubleshooting if one understands the process better.
So, Attached is a file of comments in ArduinoISP sketch.
It begins with "this sketch turns the arduino into a AVRISP".
What is an AVRISP?
Again after much searching AVR, are simply the initials of the guys that developed small processors like the ATtiny 85.
Alf(Egil Bogen) Vegard (Wollan) RISC processor. (aka Advanced Virtual RISC)
And RISC= Reduced Instruction Set Computing.
And ISP = In System Programmer
For those who want visual confirmation that download was successful and that the Programmer is running try this:
// Put an LED (with resistor) on the following pins:
// 9: Heartbeat - shows the programmer is running
// 8: Error - Lights up if something goes wrong (use red if that makes sense)
// 7: Programming - In communication with the slave
9 Comments
5 years ago
This is a waist of time, just load the Digistump driver and the Arduino files and program these directly via the USB port.
Reply 4 years ago
And if you accidentally overwrote the bootloader? How about if you don't have a microUSB cable handy (unlikely but possible)? Or if you need the extra 1.5k of flash that's used by the bootloader?
Reply 4 years ago
Or if you wasted hours struggling on your Mac and win laptop attempting to get the right micro USB cable and the correct old usb2 external hub, and the correct drivers and yet the digiusb driver still isn’t found....grrrrr
4 years ago
Hello, from Atlantic Canada.
And thank you, so much, for sharing this Instructable, as I have accidentally "blown out" the micronucleus bootloader from one of my DigiSpark clone boards (like the one shown in your photos here).
In Step 5 (burning the bootloader), you wrote:
"From the IDE Tools, Menu, Clock. Select: 8MHz Clock speed."
I thought that these boards have the ATtiny85 fuses set to run the chip at 16 MHz (from the PLL oscillator). Why, then, does your instruction say to select 8MHz? Does that menu setting ("Clock") change the fuse bits while burning the bootloader?
Thanks and very best regards.
6 years ago
Hi, this link does not work https://github.com/damellis/attiny/zipball/Arduino...
Any other referral known? Thx!
Reply 4 years ago
His link should have been https://github.com/damellis/attiny but https://github.com/SpenceKonde/ATTinyCore is much more up to date.
Reply 6 years ago
Hi,
Sorry, you will need to do Google search.
Dolon12
Reply 6 years ago
Hi, do you mean to install Arduino? If yes, I have 1.6.7 already at my desktop. I thought there is something special in your link.
Bests,
Tomasz
4 years ago
There's a simple trick to using the Digispark directly on a breadboard without needing wires soldered to the power/ground connections like this. Simply solder in TWO pins (not all three.) for either vin./gnd OR 5v/gnd. Then solder in the 6 pins for D0-D5. Now it fits onto a breadboard just fine (just be careful of which side you use as the power/ground will only be correct on one side but not on the other when the breadboard is one of those that has power on the outside on one edge and ground on the outside of the other, such as the one shown above. Case in point: I just realized I plugged mine in backwards when taking the photo. So if I HAD plugged in power, I'd have fried it. But if I put it on the other side of the breadboard, it'd be fine.)