Program an ATtiny85 Using an Arduino Uno v1.8.13 (2020-07-10) ================================================ Download "Windows Installer, for Windows XP and up" from https://www.arduino.cc/en/Main/Software. This is the Arduino IDE - integrated development environment. Install the software with default options. Take note of where it installs; you'll need to know this when it comes time to add libraries for some of the cool devices that work with Arduino. The path to the Arduino.exe app is probably "C:\Program Files (x86)\Arduino". The path to the libraries is probably "C:\Program Files (x86)\Arduino\libraries". This is where you need to drop any new libraries you download from Github, etc. On the subject of libraries, you'll probably receive them as .zip files. Do your self a favour/favor right now and create a folder on your desktop labeled "Ardy_Libs" and drop the zip file in there. Once expanded, you can drag them to the libraries folder listed above. 1) Now we can add support for the ATtiny chips like the ATtiny85 and ATtiny84 to the Arduino URL Board Manager. Startup the Arduino 1.18.13 IDE and click "File | Preferences". Further down you should see "Additional Boards Manager URLs:". Click the right-adjacent dropdown box and add the following text on a new line, regardless of how many other text lines may or may not be there: "https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json" Now the IDE will be aware of the various ATtiny devices like ATtiny85, ATtiny84, etc. in addition to the AVR boards like UNO, etc. Note that these devices are not to be confused with the newer megaTinyCore devices like ATtiny3216, etc. They require their own driver cores. Info can be found here: "https://forum.arduino.cc/index.php?topic=623194.0" 2) Make note of the location of where the preferences.txt file will be stored. This is important if your Arduino IDE blows up like it did last week in version 1.18.12. The default location is "C:\Users\yourname\Appdata\Local\Arduino15". Click "OK" and close the IDE. It must NOT be running if you open preferences.txt out of curiousity. 3) Startup the IDE. Install the ATtiny Board Package under "Tools | Board | Boards Manager". You will need to go to the end of the list to see "attiny by David. A Mellis". Click "Install". Close the IDE and reopen it. Under "Tools | Board" you should now see "ATtiny Microcontrollers". Do not select it yet. 4) We need to put the Arduino Uno into ISP programmer mode by loading up a sketch. Then we can configure it to program the ATtiny. Put the Arduino Uno into ISP Mode with "File | Examples | 11. Arduino ISP | ArduinoISP". Close the other sketch that opened when you started up the IDE but keep this sketch open. Click the Upload button (right-facing arrow) and wait until the green activity line This will load a new sketch to run on the Uno so it can program the ATtiny once it's wired. However, we need to "point" to the Uno so under "Tools | Board", ensure "Arduino AVR Boards | Arduino Uno" is selected. Under "Tools | Port", it should read "COMxx (Arduino Uno)". Under "Tools | Programmer", we need to see "AVRisp mkII". This is required to program the Uno. We will use "ArduinoISP" to program the ATtiny later. 5) Wire the ATtiny85 on the breadboard so it can be programmed via SPI. Arduino --> ATtiny85 5V Vcc (physical pin 8) GND GND (physical pin 4) Pin 13 (D13) Pin 2 (physical pin 7, D2) SPI SCK Pin 12 (D12) Pin 1 (physical pin 6, D1) SPI MISO Pin 11 (D11) Pin 0 (physical pin 5, D0) SPI MOSI Pin 10 (D10) Reset (physical pin 1, RESET) 6) Wire a 10uF or larger electrolytic cap from the Arduino UNO's RESET pin (+) to the Arduino UNO's GND pin (-). Make sure the side of the cap with all of the "-" symbols is connected to ground. The UNO RESET pin is normally pulled high via an internal pullup resistor. When the UNO is reset, the RESET pin is normally pulled low briefly. While it's low the bootloader looks for a connection via USB for programming, and if it's not found it proceeds with booting the user program. By using the large cap, we artificially keep RESET high so the UNO can program the ATtiny. We'll remove the cap once the ATtiny85 is programmed. Note: it is imperative the cap not be connected to ground until after the Uno has been programmed with the ArduinoISP sketch. Whenever you wish to reuse the Uno, the cap must not be connected to ground. We only connect it to ground to program the ATtiny. I am repeating myself here because this causes the most grief for people. 7) You have already uploaded the ArduinoISP sketch to the Uno while the cap was disconnected. Now under "Tools" choose "Board | ATtiny Microcontrollers | ATtiny25/45/85". Under "Tools", configure the ATtiny85 for: Board: "ATtiny25/45/85" Processor: "ATtiny85" Clock: "Internal 8 MHz" Port: If your USB cable is plugged into the UNO, you'll see the correct port listed here amongst the others available. If the port is not labeled as your UNO, Right-click on "This PC" on your desktop, choose "Manage", select "Device Manager" then click "Ports (COM & LPT)" to see which port was assigned to your UNO. 8) Place a 470ohm resistor and LED in series between ATtiny85's physical pin 5 (signal) and physical pin 4 (GND). The longer LED anode (+) should be pointed towards physical pin 5 and the shorter LED cathode (-) toward GND. This will be for a modified Blink.ino sketch so we know the ATtiny85 has been programmed properly. 9) In the ArduinoISP sketch under "Tools", select Programmer: "Arduino as ISP". Importantly note that the default to use the Arduino Uno normally is "AVRISP mkII". Under "Tools" choose "Burn Bootloader" which will write a new bootloader onto the new ATtiny85 chip. Once this is accomplished with no errors, you need not do this step again for any sketches you upload to the ATtiny. 10) Open the Blink Sketch found under "File | Examples | 01.Basics | Blink". Edit the sketch by replacing "pin 13" or "LED_BUILTIN" with "0"; it's in there 3 times. Now make sure the cap is connected to both the Uno RESET pin and ground. With "Arduino as ISP" still selected, click the right-facing arrow to upload & run the modified Blink sketch. The Tx and Rx LEDs on the Uno should flash for a few seconds as the sketch is uploaded. Afterwards the LED should flash on for second and then off for a second. Congratulations - you have installed a bootloader on the ATtiny85 and tested it with the Blink sketch! Now quickly disconnect the cap from ground: it is only used to program the ATtiny and not the Uno. 11) If you wish to use your Arduino Uno for other activities, you will need to change the Programmer under "Tools" from "Arduino as ISP" to "AVRISP mkII". The End