Skip to main content

How To Turn Your Arduino Into An ISP — Programming The ATmel ATtiny85


arduino as isp
Sometimes, using a pre-built Arduino board in a project is overkill, or just oversized. The ATtiny85 is an inexpensive but surprisingly capable microcontroller that can help with reducing the footprint of your project. Here’s how you can program an ATtiny for use in
your project.
The Arduino platform is an amazing tool for learning, but sometimes the supported Arduino boards don’t quite fit where you need them to. With the Arduino Uno (the most common model) measuring in at about 65mmx50mm, it’s easy to see how it might be the largest component in some projects. There are other boards like the Nano that are much smaller (my Nano knockoff is 43mm by 17mm, 4.5 times smaller), but even then, sometimes that’s just too large. What if, say, you want to build a wearable device, maybe it’s just a blinking LED for your dog to wear at night. Once you factor in a battery and so on, it can get fairly large.
Cue the ATtiny line, the hero to our problem. The ATtiny’s namesake is obvious. You can find it in a DIP-8 package (dual inline package – 8 pins), which is about 9mm squared. In true nature to its namesake, the ATtiny is minuscule, but in more ways than just its physical size. The ATtiny85, which is used for this article, only has 8KB of program flash storage, 512 bytes of RAM, and 512 bytes of EEPROM (permanent storage outside of program storage).
Now the problem is programming one of these tiny guys. There are a few tutorials online for this, but I found them to be slightly incomplete or lacking in instructions.

ISP – In System Programmer

An In System Programmer (ISP) isn’t as fancy as it sounds. Typically, an ISP for an ATmel chip consists of a device with a six pin connector USB cable. The ISP pins are really easy to spot on Arduinos, they’re typically located opposite the USB connector. ATmel chips are intended to be programmed via the ISP pins, but the Arduino platform has implemented a USB to serial adapter on the board to eliminate the need for the ISP device. Despite this, they have left the ISP pins available on many, if not most models.
Because our ATtiny chips don’t have the USB to serial device that the Arduinos have, it is required that they are programmed using an ISP. ATmel ISP devices are fairly expensive, at least in comparison to the cost of an Arduino itself, so we’ll save ourselves the money and the shipping time by programming an Arduino to behave as an ISP.
We do this by opening up the Arduino IDE and selecting ArduinoISP from the sample sketches.
Upon opening the sketch file, you’ll see some information about the expected behavior of the code. In this file, we must make a quick alteration for our ISP to communicate with the Arduino IDE properly.
At line 220 we find the setup() function.
We need to change BAUDRATE to 19200 so the line reads
From what I’ve read, the Arduino IDE received an update that broke compatibility with this ArduinoISP firmware. The Arduino and the IDE were attempting to communicate at different baud rates and that resulted in failure to utilize the Arduino as an ISP, despite the firmware flashing properly.

ATtiny Libraries

The Arduino IDE supports a variety of different microcontrollers and boards, but unfortunately, the ATtiny series are not included. This means we have to grab support for them ourselves.
The way that worked for me was to add the below URL to the Additional Boards Manager URLs under the Arduino IDE preferences,
restart the IDE, open up the Boards Manager under Tools -> Board -> Boards Manager and then search for the ATtiny package and install it.
Once that’s done, you can start to build your circuit for programming your ATtiny.

Building Your ISP

There are a number of ways you can build your ISP. You can build it in solderless breadboard so you can repurpose the parts, or you can make a semi-permanent solution by soldering it all together like I did. If you’re carefully soldering it all together, then you can reuse the Arduino for another project if you choose.
Looking at the first thirty-odd lines of the ArduinoISP sketch, we can find the following information about setting up the Arduino to function as an ISP.
Pin 10To Reset Pin for
Target Microcontroller
Pin 11SPI Master Out
Slave In
Pin 12SPI Master In
Slave Out
Pin 13SPI Serial Clock
Optionally, you can connect LEDs to the following pins for indicating status
  • Pin 9 – Heartbeat – Indicates ISP is running
  • Pin 8 – Error – Indicates an Error has Occurred
  • Pin 7 – Programming – Indicates Active Communication with Target
Keep in mind that these LEDs will require resistors.
Here we can see the pinout for the ATtiny85 and the appropriate connections we need to make back to the Arduino. It’s a pretty crude drawing, but I’ve labeled the pins on the ATtiny85 for convenience. It should be noted, however, that the pins are not addressed at 1,2,3..8 as they are in the diagram, they are designated within the Arduino IDE as they have been labeled in the diagonal text.
This is a much more detailed diagram of the different connections. All of the LEDs are optional, but they are useful for troubleshooting, in addition to the three status LEDs that were recommended in the ArduinoISP sketch file, there is one that simply connects from 5V to ground (with a resistor, of course), and then there’s one connected to the second pin (Pin 3 in the IDE) for testing the ATtiny with the blink test. Notice the capacitor that connects the Reset pin to ground, this is required for the Arduino to function as an ISP.
This is the Arduino ISP I built for ATtiny microcontrollers. You can see that I used the DIP-8 socket to hold the ATtiny while it’s being programmed. I’ve also left enough room on the right to install a DIP-28 socket for programming ATmega chips like the ATmega328P. The upgrade will be very straightforward, only requiring that the necessary pins for the Atmega chips be connected like we have with the ATtiny.
Once you’ve assembled your Arduino ISP, you’ll surely want to try it out. Be sure to select the appropriate settings to program through your connected Arduino and not program the Arduino itself.
For the board, we choose the ATiny 25/45/85 option, then select ATtiny85 in the processor selection, and finally, we select Arduino as ISP from the programmers. That tells the IDE everything it needs to know about the target system, including how it will be communicating with it. Now we’re ready to bring up the Blink sketch (or type it out yourself if you’re that hardcore) and try it out, just be sure to switch the pin used for blinking the LED to the one you’ve used in your circuit, that’s pin 3 if you’re using the schematic I provided. Lastly, we compile and upload the sketch by clicking Sketch -> Upload Using Programmer.
In total, my Arduino ISP that’s soldered together probably cost around three or four dollars. The ATtiny chips can be extremely inexpensive, as well, usually only about a dollar a piece. I recommend buying the DIP-8 sockets if you plan on putting ATtiny chips into projects because you might want to update some code or repurpose the chip. Soldering an IC in place is doable, but you can easily damage the IC, especially with repeated exposure, as would be the case if you were updating code a few times.
Has anyone else done anything like this? Would you like to see more Arduino stuff? Let us know in the comments below.

Comments

WHAT'S HOT

Fappening 2.0 Continues: Modern Family Actress Sarah Hyland Has Become The Latest Victim Of Notorious Hackers [Private Photos, Video Leaked]

Modern Family actress Sarah Hyland has become the latest victim of notorious hackers. Her private pictures and video have been posted online on infamous website Celeb Jihad. According to media sources, Sarah’s lawyers are planning to take legal action against the websites who choose to publish the leaked material. Meanwhile, the actual powers behind the leak are unknown.

Fedora 26 Released with Biggest Features - Download Here

Fedora 26 is the latest version of Fedora operating system. This version ships with the default GNOME 3.24 desktop environment andLinux kernel 4.11.8. Fedora 26 also marks the release of a new spin in the form of LXQt desktop edition. The other major change is the Fedora

Supermassive Black Holes Found Orbiting Each Other For The First Time

Image Credit: UCR Researchers from Stanford University have identified super-massive binary black holes at the center of Galaxy 0402+379 about 750 billion light years away. The two of the black holes are just 24 light years apart and one of them is orbiting the other. This is the first

Samsung Overtakes Fitbit In Wearable Sales For First Time

Fitbit has been a top competitor on the global wearable market for a long time, but the South Korea giant Samsung managed to steal the silver crown of the wearable market from Fitbit. According to Strategy Analytics, Samsung gained the