Programming an ATtiny85 with a USBasp

In this tutorial we are going to be programming an ATtiny85 with a USBasp. If you don’t know what An ATtiny85 is you may want to read my article:

What is an ATtiny85? first for some information.

There are a few different ways you can program an ATtiny85. However in my opinion using a USBasp is the cheapest and easiest. If you haven’t got a USBasp you can get one for under £10 and you can use it to program a whole host of microcontrollers.

What is a USBasp?

A USBasp is a small board that plugs into a USB port on a laptop and with it you can program microcontrollers via ISP. ISP is in system programming. It also means in circuit serial programming. You connect up your programmer to a standard 6 pin header on the circuit board and program the microcontroller up while it is powered and in circuit. The major advantage is that you don’t have to unplug the microcontroller.

How to install Arduino IDE on Windows 7,8 and 10

Go to the Arduino IDE website and download the Arduino Windows ZIP. Unzip the folder and inside it you will find arduino.exe. This is the installation file and clicking on it will install it however you also need to install a driver for the USBasp. This is not as straight forward as you may think. Microsoft decided a while ago that drivers on Windows had to be digitally signed or it wouldn’t let you use them.

There is a way you can use them by disabling driver signature enforcement however this is not easy as you have to get to the restart the machine and press buttons at the correct time to even get near the advanced startup screen. If you want to try this method then follow the steps below.

How to disable driver signature enforcement for Windows

Click the Start menu and select Settings.

• Select Update and Security.• Click on Recovery.• Then Restart now under Advanced Startup.• Click Troubleshoot.• Select Advanced options.• Click Startup Settings.• Then Restart.• On the Startup Settings screen press 7 or F7 to disable driver signature enforcement.

I had it all running nicely on a Windows 10 laptop. Only to come back to it one day to find it wouldn’t work any more. After a lot or research on the internet I found out that Windows 10 had done an update and either re-enabled driver signature enforcement that stopped the driver and therefore Arduino IDE and the USBasp from working or it had decided to erase the driver! I’m not sure which but don’t you just love Windows OS.Luckily I found a much easier way after Googling. That was to download this file.

https://protostack.com.au/download/USBasp-win-driver-x86-x64-v3.0.7.zip

This file contains drivers that are digitally signed so you don’t need to go through the above steps to driver signature enforcement.Unzip the folder and run the InstallDriver.exe file. This worked for me and checking the device manager showed there was now a driver for my USBasp.This was also another of the nails in the coffin for me and Windows.

Before I sorted the Windows driver problems I was getting the message

error: could not find USB device with vid=0x16c0 pid=0x5dc vendor=’www.fischl.de’ product=’USBasp’

If your getting this message the problem is the driver, even if it is showing in the device manager.

How to install Arduino IDE on Linux mint

The easiest way to install Arduino IDE on Linux mint is to do it through the software manager.Just click on software manager and type “arduino IDE” in the search box, then select install. Its as simple as that.Alternatively go to the Arduino IDE website and download the software you need. For me that was Linux 64 bit. There are downloads for different systems so make sure you get the correct one.

Once you have downloaded it right click on the compressed file to bring up a sub menu and select “Extract here”. A folder will appear which will contain the file “install.sh”. Double clicking on it will bring up a box then you just click on “Run”. The Arduino IDE icon will then appear on the desktop.

There is another way and that’s to download the software from the website. Then uncompress it and install it by typing loads of time consuming things in the terminal window and hope it likes what’s going on. Most times I do this by following instructions on the internet it doesn’t like what I’ve typed and some cryptic message is displayed.

When I google the message I got lots of endless explanations that want me to type other things in and I really don’t know what I’m doing. I just use the simple method of the software manager.

USBasp driver

In Linux you don’t need to install a driver for USBasp. However you still might get the message:

An error occurred while uploading the sketch

avrdude: Warning: cannot open USB device: Permission denied

avrdude: error: could not find USB device with vid=0x16c0 pid=0x5dc vendor=’www.fischl.de’ product=’USBasp’

At first I thought it was similar to the Windows driver issue. There is a driver but if you look at the error message more closely Linux is denying permission for it. So although its there you can’t use it!

Well you can but you have to change the permissions. Open up the terminal and type:

lsusb

You will get a list of devices and you are looking for something like this:

Bus 003 Device 002: ID 16c0:05dc Van Ooijen Technische Informatica shared ID for use with libusb.

You have done this so you can see what the bus and device numbers are for the USBasp. Then in the terminal, type:

sudo chmod 666 /dev/bus/usb/003/002

You will have to change the numbers at the end for the bus and device numbers you discovered in the lsusb command. Everything should now work correctly but you will have to do this each time you connect up the USBasp.

Setting up Arduino IDE for the ATtiny85 and USBasp

To start programming an ATtiny85 with a USBasp we have to install some stuff and change some settings.

To do this click on Arduino IDE to run the software and when its open, click on FILE and the option second from bottom PREFERENCES, near the bottom of the page that opens you will see a long white blank box with “Additional Boards Manager URLs:”In that box copy and paste the following:

https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json

Click OK.

1Screenshot-at-2021-12-17-12-11-13

Then click on “tools” and then “board” and board manager.

Then on the screen that comes up, scroll down to “attiny” by David A. Meliis, and click on the install button. Then click “close”.

3Screenshot-at-2021-12-17-12-13-46

Now if you go to the tools menu and move the arrow down to “Board: “Arduino Uno” a sub menu will pop up and you will see ATtiny Microcontrollers with another little arrow next to it. Move the cursor to that and you get the option to choose ATtiny 25/45/85 or ATtiny 24/44/84. So select the ATtiny 25/45/85 option.

Once you have clicked on it you will exit, so go back into the Tools menu again. You will see there is now an option under Board: “ATtiny 25/45/85” that says Processor: “ATtiny25”.When you move the cursor over this another sub menu opens. Select “ATtiny85” and again you will exit the tools menu. Back into tools again but this time go to Programmer: “AVRISP mk II” and from the sub menu select “USBasp”

Programming an ATtiny85 with a USBasp – the hardware

Now that we have set that up it’s time to connect up the hardware. The easiest and quickest way is to just plug the ATtiny85 into a breadboard and connect the USBasp up to it. If you are already comfortable using breadboards you can carry on with this article, but if you are a beginner or want some more information, I have an article of building this project on a breadboard which you can read by clicking on the link below:

breadboard blinking led project

Programming an ATtiny85 with a USBasp

This is what it will look like. I’ve used the 10 way to 6 way converter that you get with some USBasp’s and just plugged wires to both. The diagram below shows the six pins to wire to.

Programming an ATtiny85 with a USBasp

The adapter has the connections named on it which makes things easier. On the one side you can see you have GND, MOSI and VCC.

Programming an ATtiny85 with a USBasp

On the other side you have the MISO, SCK and Reset.

breadboard wiring

As you can see from the picture above I’ve wired a 390R resistor from pin 3 to a LED that goes to the blue line on the breadboard. Don’t forget to wire the blue line to pin 4 (GND) with another lead.

If you are a beginner You might want to read about breadboards for more information and resistor colour codes.

Actually programming the ATtiny85

Make sure the USBasp is set to provide 5V. You do this by having the jumper in the position shown in the picture below. You can move it to the other two pins and it will provide 3.3V or if you remove it completely it doesn’t power the circuit.

USBasp set for 5V

With the USBasp wired to the breadboard with the ATtiny85 plug it into the USB socket on the laptop. Run Arduino IDE again, all the changes you made above for using it with the USBasp and the ATtiny85 will be stored.

Open the file Blink by clicking in the top corner, click on File/ Examples/ 01.Basics/ Blink

The page below will open, you need to alter where it says “LED_BUILTIN” to “4”. You have to do it for all three  of them.

You will end up with something like the picture below. The reason we’ve changed it to 4 is because we have wired the LED to PB4 of the ATtiny85.

Uploading the program or sketch

Next click on the “tick” under File, then the “arrow” to the right. This will upload it to the Attiny85 and the LED should now be flashing. If it doesn’t, check your wiring and that the LED is the correct way round!

If you look you will see two delay values of 1000 for high and low. Change them to 500 then click on the “tick” and the “arrow” again. The flashing will now be twice as fast. These values can be set independently, the HIGH time is the time the LED is on with the LOW being off.

This is now programmed and if you disconnect it from the USBasp and connect it to a 5V supply the LED will flash

If you disconnect the breadboard from the USBasp and to a 5 Volt supply the LED will flash as it is now programmed to do that job.

USBasp firmware update

​If you want to update the firmware on your USBasp I have a guide on hot to do it here:

USBasp firmware update.

Final thoughts on Programming an ATtiny85 with a USBasp

Although it might seem a lot of work to get a LED to flash. That’s not really the point of the exercise. What you have done is set your laptop up and learned programming an ATtiny85 with a USBasp. In this case we just flashed an LED but this microcontroller is capable of much more.

There are lots of projects that you can build now that you are capable of programming. You could also get into learning how to program yourself and that opens up even more ideas. If you are struggling with the instructions above just break it down into individual steps. Once you have got the hang of one thing move onto the next.

Before I knew how to do this I looked at what it entailed and thought it was too difficult but I’m glad I stuck with it.