Despite ATtiny series is considered extremely cheap and useful, still there is a lack of projects and tutorials about it. In this tutorial, you will learn how to start building applications using ATtiny13 microcontroller programmed using Arduino IDE.
Parts you will need
- Arduino (Uno or any other Arduino)
- ATtiny13 or 13a
- Jumper Wires
In order to connect the hardware you should first orient the ATtiny as shown in the image.
First, connect Arduino 5V to ATtiny Pin 8. Respectively, connect GND to Pin 4, Pin 13 to Pin 7, Pin 12 to Pin 6, Pin 11 to Pin 5, and finally Pin 10 to Pin 1.
Programming the ATtiny13
To program ATtiny13 we should set our Arduino as a programmer. This could happen by uploading ArduinoISP sketch to Arduino following this path (Files-Examples-ArduinoISP) in the IDE.
Now our Arduino is ready to program ATtiny 13, but still we have to set up the ATtiny by installing its core files. In this tutorial, files by sleepmanj is preferred.
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.
Burning the Bootloader to the Attiny
In fact, the bootloader is a piece of firmware in your microcontroller that allows installing new firmware without the need of an external programmer.
In order to start programming ATtiny 13, we must burn Bootloader to it. There are two steps to achieve this: first, go to Tools-Board and select ATtiny13, and second, click the Burn Bootloader button at the bottom of the tools drop-down menu.
You should pay attention to your ATtiny version, navigate to Tools-Processor Version and select either ATtiny13 or ATtiny13a depending on your chip.
After burning the Bootloader, our ATtiny is now ready to be programmed. You can try now Arduino IDE examples like the Blink sketch.
To make sure that Blink will work correctly, you should first check the diagram below.
Right here, Pin 3 is defined in hardware as 4, now let’s take a look at the edited code:
Next, modify your circuit by adding an LED between Pin 3 and GND with a suitable resistor as shown in the picture.
If you faced any issues while building this project, you can check this list to troubleshoot your project:
• 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.
You also may need these components while trying to figure out what’s wrong: 10uf electrolytic capacitor and any large electrolytic capacitor.
Now all set, it is time to test new ideas and applications with ATtiny programmed using Arduino IDE! This tutorial was posted by NotoriousRapper2Chainz on Instructables, you can know more details by checking this link.