Sunday, January 5, 2014

Programming the Trinket with the Arduino IDE in Windows

I am using the Windows Arduino IDE to program the Trinket. This has been trying at times so I thought I'd share my experiences here. You can find a lot of information on solving problems on the Adafruit website, but I find it takes a while to get to what your looking for. Hopefully this will save some headaches for others who might also like to use the Trinket.

  To get started, make sure you've done these things:


  1. Updated the ATTiny85 section of your avrdude.conf file.
  2. For windows, make sure to install the USBtiny drivers 
  3. Under Tools->Board Menu select the Adafruit Trinket 8MHz
  4. Under Tools->Programmer select USBtinyISP

  Note: The Trinket doesn't have a USB Serial interface so you won't see a COM port for it.

 To upload to the Trinket, these instructions are handy: 

  1) Under Tools->Board Menu Adafruit Trinket 8MHz is selected.
  2) Under Tools->Programmer USBtinyISP is selected.

  The next steps are timing critical:
  3) Press Ctrl+Shift+U to Upload code using the programmer. (The sketch will start compiling)
  4) Press the button (don't hold it down!) on the Trinket toward the end of the sketch compiling, you want          the red LED to be blinking when the code is trying to upload.
  5) The red LED on the Trinket should pulse. This means it is ready to receive the sketch.
  6) WATCH the RED LED!!  If your sketch is uploaded, it should turn solid briefly before going off.
       If the red LED turns solid, it is likely that your sketch uploaded even if you get an error.

 Problems I had and things I did to fix them: 

 Problem:  
      The red LED does not flash when I press the reset button and I always get the error message below when trying to upload.
      avrdude: Error: Could not find USBtiny device (0x1781/0xc9f)
   Try: 
      -  Unplug the Trinket and plug it back in.
       -  If using a USB port on your computer, try using an old USB 2.0 HUB if you have one. This has been much more reliable for me. An error is usually reported but the sketch still uploads and runs.
 Problem
      When trying to upload, the red LED was flashing but it did not turn solid, my code did not upload and I got an error:
      avrdude: Error: Could not find USBtiny device (0x1781/0xc9f)
  Try:
     -  You probably missed the time window for the upload. Try again, and wait longer before pressing the button the Trinket. (This happens A LOT!)

  Problem:
       When trying to upload, the red LED was flashing but I got an error:
        avrdude: error: usbtiny_receive: usb_control_msg: sending control message failed, win error: A device attached to the system is not functioning. (expected 4, got -5)
  Try:
     - Did the red LED turn solid? If so, your sketch is likely to have uploaded anyway.
     - If not, make sure your avrdude.conf is updated.

  Problem:
       When trying to upload, the red LED was flashing but it did not turn solid, my code did not upload and I got an error:
       error at ...  avrdude.conf:1524 unrecognized character: "i"
  Try:
     - Comment out line 1524 in the avrdude.conf file which reads in my file:
             is_at90s1200     = yes;
 ( you can comment out the line by putting a # sign in front of it. )

   More avrdude problem solving for the Trinket ( or Gemma) ...

3 comments:

  1. Thank you SO MUCH for posting this article, Jennifer!!! It literally saved my week. I'm completely new to Adafruit's trinket, and needed some of its key points simply explained. My problem? Timing between the IDE's upload process and synching it with the trinket's bootloader mode - JUST LIKE YOU SAID :) I didn't realize just how critical that timing was - which your article stressed and Adafruit's docs do not (not enough for newbies, anyway). OK, i have been rambling a bit, but you should get serious props for this article . Again, THANK YOU!!!!

    ReplyDelete
  2. Here's another possible problem and solution.

    Problem:
    When trying to upload, the red LED gives a single ~3 second pulse and does not flash.
    avrdude: Error: Could not find USBtiny device (0x1781/0xc9f)
    Try:
    - A different USB cable. The first USB-mini cable I used was not able to transmit data (power only).

    ReplyDelete