How to Program ATtiny85 Using Arduino IDE: Step-by-Step Guide
To program an
ATtiny85 using the Arduino IDE, first install the ATtiny board support via the Board Manager, then connect the ATtiny85 to your Arduino as an ISP programmer. Finally, select the ATtiny85 board and programmer in the IDE and upload your sketch.Syntax
Programming the ATtiny85 with Arduino IDE involves these main steps:
- Install Board Support: Add ATtiny85 boards via the Board Manager.
- Connect Hardware: Use an Arduino as ISP to connect to the ATtiny85 pins.
- Select Board: Choose ATtiny85 and clock speed in the Tools menu.
- Select Programmer: Choose Arduino as ISP.
- Upload Sketch: Use Upload Using Programmer to flash the code.
text
1. Open Arduino IDE 2. Go to File > Preferences 3. Add URL to Additional Boards Manager URLs: https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json 4. Open Tools > Board > Boards Manager 5. Search 'attiny' and install 6. Connect Arduino as ISP to ATtiny85 7. Select Tools > Board > ATtiny25/45/85 8. Select Tools > Processor > ATtiny85 9. Select Tools > Clock > 8 MHz (internal) 10. Select Tools > Programmer > Arduino as ISP 11. Upload your sketch using Sketch > Upload Using Programmer
Example
This example blinks the onboard LED connected to pin 0 of the ATtiny85 every second. It shows how to write and upload a simple sketch.
arduino
void setup() { pinMode(0, OUTPUT); // Set pin 0 as output } void loop() { digitalWrite(0, HIGH); // LED on delay(1000); // Wait 1 second digitalWrite(0, LOW); // LED off delay(1000); // Wait 1 second }
Output
The LED connected to pin 0 blinks on and off every second.
Common Pitfalls
- Wrong Wiring: Make sure Arduino pins connect correctly to ATtiny85 pins for ISP programming.
- Incorrect Board Selection: Select the exact ATtiny85 board and clock speed in the IDE.
- Using Upload Instead of Upload Using Programmer: Always use
Upload Using Programmerto flash the ATtiny85. - Missing Bootloader Burn: Burn the bootloader once to set fuses before programming.
arduino
/* Wrong way: Using normal Upload button */ // This will fail because ATtiny85 needs programmer upload /* Right way: Use Upload Using Programmer */ // In Arduino IDE, choose Sketch > Upload Using Programmer
Quick Reference
| Step | Action | Details |
|---|---|---|
| 1 | Install Board Support | Add ATtiny URL in Preferences and install via Boards Manager |
| 2 | Connect Hardware | Wire Arduino as ISP to ATtiny85 pins (MISO, MOSI, SCK, RESET, VCC, GND) |
| 3 | Select Board | Choose ATtiny85 and clock speed (usually 8 MHz internal) |
| 4 | Select Programmer | Choose Arduino as ISP in Tools > Programmer |
| 5 | Burn Bootloader | Burn bootloader once to set fuses (Tools > Burn Bootloader) |
| 6 | Upload Sketch | Use Sketch > Upload Using Programmer to flash code |
Key Takeaways
Install ATtiny85 board support via Arduino IDE Boards Manager before programming.
Use an Arduino as ISP programmer and connect it correctly to the ATtiny85 pins.
Select the correct board, processor, clock, and programmer settings in the Arduino IDE.
Burn the bootloader once to set ATtiny85 fuses before uploading sketches.
Always use 'Upload Using Programmer' to flash code to the ATtiny85.