The ATtiny13 series chips are extremely cheap and useful chips for small projects that donât need a full Arduino, but due to very outdated tutorials and a lack of information, it took me the better part of a day to figure out how to program these with the Arduino IDE.
To fix this lack of information, in this Instructable, I will show you how to program your ATtiny13 or ATtiny13a with an up to date version of the Arduino IDE.
Step 1: The Hardware You Need
Required Hardware
⢠Arduino (Uno is the easiest, but any Arduino will work)
⢠ATtiny13 or 13a
⢠Breadboard
⢠Jumper Wires
Troubleshooting Hardware (not necessarily required)
⢠10uf electrolytic capacitor
⢠Any large electrolytic capacitor (mine is 1000uf, but any capacitance 100uf and above will work best)
Step 2: Setting Up the Hardware
Connect the pins of the Arduino to the ATtiny as shown in the image or table below.
Important Note: Make sure to orient your ATtiny such that the indicator dot on your chip is in the bottom left corner as shown in the images (across from the 5v line). Orienting your ATtiny the opposite way can hurt the chip.
Arduino____________ATtiny13(a)
5vâââââââââ-Pin 8
GNDââââââââPin 4
Pin 13ââââââââPin 7
Pin 12ââââââââPin 6
Pin 11ââââââââPin 5
Pin 10ââââââââPin 1
Step 3: Setting Up the Arduino As ISP
Navigate to Files-Examples-ArduinoISP and click on ArduinoISP. Upload this sketch to your Arduino. Now your Arduino is set up as a programmer for programming other chips.
Step 4: Downloading the Attiny13(a) Core Files
To program the ATtiny13 or 13a, you will need to install the core files. For this we will be using the core files created by sleepmanj, which I find to be the easiest to install and the best to use.
To install these files, open your Arduino IDE and navigate to the files drop-down menu, then select preferences. Paste this URL âhttps://raw.githubusercontent.com/sleemanj/optiboot/master/dists/package_gogo_diy_attiny_index.jsonâ where it says âAdditional Boards Manager URLs:â. If you already have a URL here and want to add more, separate the URLs with a comma and a space.
Now navigate to tools-board and click on Boards ManagerâŚ. Now scroll down until you see DIY ATtiny and click the install button (it will default to the newest version).
Step 5: Burning the Bootloader to the Attiny
Go to Tools-Board and select ATtiny13. After selecting ATtiny13, navigate to Tools-Processor Version and select either ATtiny13 or ATtiny13a depending on your chip. Do not change any other settings until you know what they do, they can mess up what you are trying to accomplish. Finally, click the Burn Bootloader button at the bottom of the tools drop-down menu.
Important Note:You should make sure your programmer is set as âArduino as ISPâ
Step 6: Programming the Chip
Youâre at the homestretch! To make sure everything is working, letâs upload the blink sketch to the ATtiny. Navigate to Files-Examples-Basics and select Blink.
There are a few changes we will need to make though. In the program, change every instance of âLED_BUILTINâ to â4â because our ATtiny doesnât have a built in LED. This â4â corresponds to pin 3 of the ATtiny (This can get confusing, you can reference what number in the IDE corresponds to what pin on the diagram in the âTroubleshootingâ step). Now you can upload this code to your ATtiny through your Arduino by clicking the upload button.
To test to see if it worked, connect an LED (along with an appropriate resistor) between pin 3 on the ATtiny and ground as shown in the diagram and image above. The LED should be blinking on and off. If it is, congratulations! You now know how to program an ATtiny13 or 13a! You can now disconnect all wires except the 5v and ground.
If your LED isnât blinking, donât worry, proceed to the troubleshooting step to fix your problems.
Step 7: Troubleshooting
Something always goes wrong when working with new things, thatâs ok! Letâs try to fix these issues. Try these in the order they show up.
⢠Double check all of your connections and your orientation of the ATtiny and LED.
⢠Re-upload the ArduinoISP sketch to your Arduino.
⢠Connect a 10uf electrolytic capacitor between ground and reset on your Arduino. Make sure to plug in the capacitor in the correct orientation, negative goes to ground.
⢠Connect any large capacitor between the 5v and ground on the breadboard, this will help smooth out any voltage spikes.
⢠Make sure enough power is getting to the Arduino that is programming the ATtiny, a 9 volt battery might not work.
⢠Switch out your Arduino with a different Arduino
⢠Make sure youâre using an up to date IDE and up to date core files
⢠Click on tools and make sure the drop down menu looks the same as the menu shown in the âBurn the Bootloaderâ step. If something is different, change it and re-burn the bootloader.
Source: Updated Guide on How to Program an Attiny13a or 13 With the Arduino IDE