Working with ATtiny85 requires you to learn how to write a program for ATtiny85 and how to download it into its internal Flash memory. Would it surprise you to know that we can write programs for ATtiney85 in Arduino IDE? Yes, it is true. We can write, compile, create HEX files and even download the program in ATtiny85 using Arduino IDE.
Sounds interesting! Isn’t it?
So what are we waiting for? Let’s start. Follow the step-by-step process.
Step1: Download Arduino IDE software from https://www.arduino.cc/en/software. Download the ZIP folder to your local hard drive. Unzip it and from the Arduino folder, run Arduino IDE software. You will get the following screen:
Step 2: Get the ATtiny microcontrollers board support in Arduino IDE. There is no support available for ATtiny microcontrollers, so we have to download them.
To download, go to file->preferences. You will get the following screen:
In additional boards manager URLs, please copy and paste the following link:
https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json
Now go to tools->boards->board manager
In the board manager, type ATtiny and search for boards. You will get Attiny by Devid A Mellis. Click on install. And that’s it. The ATtiny microcontroller board support is now installed in your Arduino IDE.
Now once again, go to tools->boards and scroll down. You will find ATtiny25/45/85.
Select board as ATtiny25/45/85
Processor ATtiny85
Clock internal 1 MHz
Now your Arduino IDE software is ready to compile programs for ATtiny85. We can write all the programs for ATtiny85 just like we write programs for the Arduino board. We can use all Arduino functions like analogWrite(), analogRead(), digitalWrite(), digitalRead(), pinMode() etc all most all to make a program for ATtiny85.
Now the software part to program ATtiny85 is complete. But what about the hardware? How do you download the program into the internal Flash of ATtiny85? That is also simple.
Step 3: Get the USB SPI programmer.
You can use any USB SPI programmer like USBasp or any other because ATtiny85 also supports ICSP like any other AVR microcontroller. We have seen in ATtiny85 pin functions, ATtiny85 has full function SPI with MOSI-MISO-SCK pins using which we can program it. Just get any USB SPI programmer and make the following connections:
As shown in the figure, the respective pins MOSI, MISO, SCK, RESET, Vcc, and Gnd of SPI programmer are connected with ATtiny85 pins: 5(MOSI), 6(MISO), 7(SCK), 1(RESET), 8(Vcc) and 4(Gnd).
Your ATtiny85 is ready to program.
Step 4: Create HEX file for ATtiny85 program in Arduino
You write any program for any project or application for ATtiny85 in Arduino and compile it. Once it is compiled, create a HEX file for the program downloaded into internal Flash.
To create a HEX file in Arduino IDE, just go file->preference and tick the compilation checkbox. Click OK and recompile the program.
This time compilation will take longer, and you can observe the detailed compilation process in the Arduino IDE output window. Finally, you will find created HEX file in the output window, as shown in the figure.
Step 5: download HEX file into internal Flash of ATtiny85
To download the HEX file into ATtiny85, you can use any software (free to download) like ponyprog or progISP that supports USB SPI programmer. I am using progisp software to upload the HEX file into the internal Flash of ATtiny85. Here is the screen of PROGISP software:
In this, from file menu -> load the Flash with the HEX file we have created in Arduino IDE.
Select chip as ATtiny85
Select programming options as 1) chip erase 2) blank check 3) Program Flash 4) verify Flash.
Click auto button.
The program is downloaded into ATtiny85.
In summary, this is how you can write, compile, and create a HEX file for ATtiny85 using Arduino IDE and download the program using any USB SPI hardware and software.
Our next tutorial will walk you through making your first hello world application that is an LED blinking application using ATtiny85.
You may also like:
Filed Under: Featured Contributions
Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.