How to Install an ATtiny Bootloader With Virtual USB

Pages
Contributors: Shawn Hymel
Favorited Favorite 13

Example: Blinky

We should have everything set up to flash a program onto the ATtiny84 from the Arduino IDE! But first, let's simplify the hardware.

Hardware Setup

We can modify our hardware to disconnect the programming lines from the Arduino Pro Mini, which will free up some GPIO on the ATtiny. We'll still want to use the Pro Mini's voltage regulator to drop the USB voltage from 5V to 3.3V.

Warning: Make sure you unplug the USB cable from the Arduino! We don't want to short anything. From now on, we'll be using the USB micro breakout on the breadboard to program the ATtiny84.

ATtiny84 with micronucleus bootloader

The Code

Close and reopen the Arduino IDE to load the new board definition files.

Note: On Linux and OS X, you'll need to run the Arduino IDE with administrator/root privileges in order to upload sketches over USB.

In a new sketch, copy in the following:

language:c
const int led = 0;

void setup() {
  pinMode(led, OUTPUT);
}

void loop() {
  digitalWrite(led, HIGH);
  delay(1000);
  digitalWrite(led, LOW);
  delay(1000);
}

Upload and Run

In Tools > Board, you should see only one option under MyTiny Boards. Select it.

Arduino with the custom ATtiny84 board definition

This part is important! Follow these steps to upload the sketch to the ATtiny84. Because our V-USB connection does not automatically reset the ATtiny, we'll need to reset it manually as the bootloader runs for the first five seconds after power-up before relinquishing control to the user program.
  1. Unplug USB cable
  2. Press Upload in the Arduino IDE
  3. Wait for the phrase "Uploading..." to appear just above the Arduino console
  4. Plug in the USB cable
  5. Wait five seconds for the ATtiny84 to reboot and time out of the bootloader to start running our Blinky sketch

Uploading Arduino sketch to ATtiny84

And that's it! You should see the LED begin to blink on and off.

Programming an ATtiny84 from Arduino using a bootloader with V-USB