Chances are, you picked up a Trinket because it is programmable with the Arduino IDE. Note that the Trinket is not a full Arduino-compatible, it uses a different (smaller) chip than the Uno, Mega, Leonardo or Due. However, there are many small sketches and libraries that will work just fine. Some may not even need anything other than pin number changes.
Even though Trinket has a USB connector, it does not have a "Serial Console" capability, so you cannot use Serial to send and receive data to/from a computer! It will not show up as a PORT in the setup menu
There is currently a bug in Arduino 1.8.7 which requires you to select a Port before upload but we don't use Ports for Pro Trinket uploads. If you don't have a Serial Port available to select, please use Arduino 1.8.6

Arduino IDE Setup

Just follow the steps in the steps in the Adafruit Arduino IDE setup guide to easily add support for Trinket, Gemma, Pro Trinket & more to the Arduino IDE.

You will need Arduino IDE 1.6 or greater

When you're finished installing the IDE & board manager add on come back to this page to continue the Trinket guide.

Blink!

After installing the Arduino IDE with support for Adafruit's boards you can load a simple blinking LED example to test uploading to Trinket works as expected.  Open the Arduino IDE and replace the sketch code with the following blink code:

If you are using Linux you may have to be "root" running the Arduino program to have access to the USB port (or add udev exceptions)
      /*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.
 
  This example code is in the public domain.

  To upload to your Gemma or Trinket:
  1) Select the proper board from the Tools->Board Menu
  2) Select USBtinyISP from the Tools->Programmer
  3) Plug in the Gemma/Trinket, make sure you see the green LED lit
  4) For windows, install the USBtiny drivers
  5) Press the button on the Gemma/Trinket - verify you see
     the red LED pulse. This means it is ready to receive data
  6) Click the upload button above within 10 seconds
*/
 
int led = 1; // blink 'digital' pin 1 - AKA the built in red LED

// the setup routine runs once when you press reset:
void setup() {
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);

}

// the loop routine runs over and over again forever:
void loop() {
    digitalWrite(led, HIGH); 
    delay(1000);
    digitalWrite(led, LOW);
    delay(1000);
}
    
Select the Trinket 8MHz board from the Tools->Board menu
Then, select USBtinyISP from the Tools->Programmer sub-menu
When you're ready to upload, make sure the "Programmer" in the Tools menu is set to USBtinyISP!
The Serial Port menu will not show the Trinket, that's normal!

Plug in the Trinket, make sure you see the green LED lit (power good) and the red LED pulsing.

Press the button if the red LED is not pulsing, to get into bootloader mode.

Click the Upload button (or select File->Upload)

If everything goes smoothly you should see the following (no red error messages) and of course, the red LED on the trinket will blink on/off once a second

Something Went Wrong!

If you get the error message avrdude: Error: Could not find USBtiny device (0x1781/0xc9f)


That means the bootloader wasn't active. Make sure to press the button on the Trinket to activate the bootloader before clicking the Upload button.

If you get a lot of red text, errors and also a warning about Verification Failed


Try again! Make sure you have a good USB cable, try connecting through a hub if you have one.

On Linux if you get the error message "usbtiny_receive: error sending control message: Protocol error (expected 4, got -71)"

These can generally be ignored and should not interfere with the program upload.  Unfortunately Linux's USB core is a little flakey communicating with the ATtiny85 processor on the Trinket/Gemma and can cause these errors.  If an upload does fail, try it again as it is likely an intermittent issue.

This guide was first published on Sep 03, 2013. It was last updated on Mar 08, 2024.

This page (Setting up with Arduino IDE) was last updated on Mar 08, 2024.

Text editor powered by tinymce.