Advertisement

Quick Links

Introducing Trinket
Created by lady ada
Last updated on 2014-07-03 03:30:16 PM EDT

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the Trinket and is the answer not in the manual?

Questions and answers

Summary of Contents for adafruit learning system Trinket

  • Page 1 Introducing Trinket Created by lady ada Last updated on 2014-07-03 03:30:16 PM EDT...
  • Page 2: Table Of Contents

    GPIO Pins Reset and Regulator Output Starting the Bootloader About the bootloader Trinket USB Drivers for Windows Special Notes on using Trinket with Linux How to start the bootloader Setting up with Arduino IDE The Fast Way The Slow Way Step 0.
  • Page 3 Uploading with AVRdude Programming in a Blink example 16MHz vs 8MHz Clock Power Tradeoffs How to activate the 16 MHz clock ...on AVR-GCC ...Arduino IDE Repairing bootloader Downloads Datasheets Source code Schematics © Adafruit https://learn.adafruit.com/introducing-trinket Page 3 of 48 Industries...
  • Page 4: Introduction

    Introduction Trinket may be small, but do not be fooled by its size! It's a tiny microcontroller board, built around the Atmel ATtiny85, a little chip with a lot of power. We wanted to design a microcontroller board that was small enough to fit into any project, and low cost enough to use without hesitation.
  • Page 5 USB v2 port or a USB hub in between There are two versions of the Trinket. One is 3V and one is 5V. Both work the same, but have different operating logic voltages. Use the 3V one to interface with sensors and devices that need 3V logic, or when you want to power it off of a LiPo battery.
  • Page 6: Guided Tour

    Guided Tour Let me take you on a tour of your Trinket! Each trinket is assembled here at Adafruit and comes chock-full of good design to make it a joy to use. Mini-B USB co nnecto r - We went with the tried and true mini-B USB connector for power and/or USB bootloading.
  • Page 7 External Reset Pin - we bring out the reset pin so you can reset or restart your Trinket on the road. If the Trinket is in a box or otherwise hard to get to, you can wire up a button to this pin for an external reset button.
  • Page 8: Pinouts

    Pinouts The following shows measurements in mm, both version of the Trinket have the exact same dimensions for hole placement & outline © Adafruit https://learn.adafruit.com/introducing-trinket Page 8 of 48 Industries...
  • Page 9 There are two versions of the Trinket: 3V and 5V. They are almost identical but there are slight differences in the pinouts: one has a 3V output pin in the bottom right, the other has a 5V output pin instead ©...
  • Page 10: Power Pins

    (positive) pin here! You can connect up to 16V DC. If you have a 3V Trinket, you'll want at least 3.5V input to get a good 3.3V output. If you have a 5V trinket, 5.5V or higher is © Adafruit https://learn.adafruit.com/introducing-trinket...
  • Page 11: Gpio Pins

    (http://adafru.it/aUD) On a 3V Trinket, the GPIO are 3.3V output level, and should not be used with 5V inputs. On a 5V Trinket, the GPIO are 5V output level, and can be used with 3V inputs but may damage...
  • Page 12: Reset And Regulator Output

    16V DC from the BAT+ or USB connection and regulate it down to a steady 3.3V or 5.0V DC so its safe to use with your sensors and LEDs. On a 3V Trinket, this output will be about 3.3V.
  • Page 13: Starting The Bootloader

    A bootloader is a tiny piece of software residing on the microcontroller that that helps load your own code into the remaining space. One of the challenges with the Trinket is that we wanted to have a built-in USB bootloader, but the ATtiny85 doesn't have built-in USB hardware! There are existing USB bootloaders that can work on the 't85 but they use other companies' USB VID/PIDs.
  • Page 14: Special Notes On Using Trinket With Linux

    How to start the bootloader Before you try to upload code to the Trinket it must be in the Bootloader Mode. That means its listening for a sketch or program to be sent to it When the Trinket is in bootloader mode, the red LED will be pulsing.
  • Page 15: Setting Up With Arduino Ide

    Setting up with Arduino IDE 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.
  • Page 16: Step 1. Add Attiny85 Support

    Trinket support is not native to the Arduino IDE but, luckily, adding it takes only a few minutes and you only have to do it once! This tutorial will base the IDE off of v1.0.5 which is current at time of writing. You can try later versions but v1.0.5 is at least guaranteed to work Adding Trinket support does not affect any other boards that are affected so you can continue to use the IDE with any Arduino board currently supported.
  • Page 17: Step 2. Updating Avrdude.conf

    The second step is to update the AVR chip program upload helper to be a little more patient with the ATtiny85 bootloader we have on the Trinket. We will update the description of the chip's erase cycle to be longer, to avoid timeouts and errors.
  • Page 18 Rename the old avrdude.co nf to avrdude.bak and copy over the new avrdude.co nf to the same folder © Adafruit https://learn.adafruit.com/introducing-trinket Page 18 of 48 Industries...
  • Page 19: Step 3. Update 'Ld' Linker

    On Windows: explore the Arduino folder and get to the hardware\to o ls\avr\bin subfolder, you'll see a lot of files starting with avr-xxx. On Mac: Explore the App and find Adafruit Arduino .app/Co ntents/Reso urces/Java/hardware/to o ls/avr/avr/bin © Adafruit https://learn.adafruit.com/introducing-trinket Page 19 of 48 Industries...
  • Page 20: Blink

    Now restart the Arduino IDE. You are done with setup! Now it's time to say "hello, world" to your new Trinket with the basic Blink sketch. Blink! OK let's practice uploading a sketch by uploading the classic Blink sketch. This program with blink the onboard red LED that is connected to pin #1.
  • Page 21 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.
  • Page 22 Then, select USBtinyISP from the To o ls->Pro grammer sub-menu 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.
  • Page 23: Something Went Wrong

    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! © Adafruit https://learn.adafruit.com/introducing-trinket Page 23 of 48 Industries...
  • Page 24: (0X1781/0Xc9F)

    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 Check that you updated the avrdude.conf file above - if you don't update the description of...
  • Page 25 © Adafruit https://learn.adafruit.com/introducing-trinket Page 25 of 48 Industries...
  • Page 26: Programming With Arduino Ide

    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.
  • Page 27: Analogread()

    This is a bit confusing because the analog pins are numbered differently than the digital pins! analogWrite() There are a few PWM outputs on the Trinket, you can call analogWrite() on digital #0, #1 and For example, to pulse the built-in LED slowly, upload this code:...
  • Page 28: More

    We also know the following libraries work: Adafruit NeoPixel (http://adafru.it/aZU) - control up to ~150 Neopixels via a Trinket! SoftwareSerial - the built in SoftSerial library can (at least) transmit data on any digital pin. More as we do more testing and verification! ©...
  • Page 29: Programming With Avrdude

    Programming with AVRdude For more technical users, rather than using the Arduino IDE, they may want to program the Trinket directly with AVR-GCC as the compiler, vi/emacs as their editor and AVRdude as the uploader. That's easy to do! Target the Attiny85 as the chip used in avr-gcc, with F_CPU at 8MHz using the internal oscillator.
  • Page 30: The Long Way

    If you want to update your avrdude.conf by hand, its not too hard. Open up that exact file in your favorite text editor and find the following text #------------------------------------------------------------ # ATtiny85 #------------------------------------------------------------ © Adafruit https://learn.adafruit.com/introducing-trinket Page 30 of 48 Industries...
  • Page 31 Delete the text after the Attiny85 header text starting with part and onto until the next header (in ours, that was ATmega640 © Adafruit https://learn.adafruit.com/introducing-trinket Page 31 of 48 Industries...
  • Page 32 ## Try the AT90S2313 devcode: avr910_devcode = 0x20; signature 0x1e 0x93 0x0b; reset = io; chip_erase_delay = 900000; pgm_enable "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", © Adafruit https://learn.adafruit.com/introducing-trinket Page 32 of 48 Industries...
  • Page 33 "1 0 1 0 0 0 0 0 0 0 0 x x x x a8", "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; © Adafruit https://learn.adafruit.com/introducing-trinket Page 33 of 48 Industries...
  • Page 34 " 0 1 0 0 1 0 0 0", " 0 0 0 x x x x x", " x x x a4 a3 a2 a1 a0", " i i i i i i i i"; © Adafruit https://learn.adafruit.com/introducing-trinket Page 34 of 48 Industries...
  • Page 35 "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", "x x x x x x x x o o o o o o o o"; min_write_delay = 9000; max_write_delay = 9000; © Adafruit https://learn.adafruit.com/introducing-trinket Page 35 of 48 Industries...
  • Page 36: Uploading With Avrdude

    -c usbtiny -p attiny85 Now plug in the Trinket into the computer's USB port and/or press the reset button to enter the bootloader. You should see the red LED pulsing. Now press return, you should get the ©...
  • Page 37: Programming In A Blink Example

    -c usbtiny -p attiny85 -D -U flash: w: trinketblink.hex (note the extra -D) As before, type out the command, then press the reset button to start the bootloader and © Adafruit https://learn.adafruit.com/introducing-trinket Page 37 of 48 Industries...
  • Page 38 USB data at the same time. This causes the USB reply to avrdude to be delayed and avrdude to spit out the retry alert. © Adafruit https://learn.adafruit.com/introducing-trinket Page 38 of 48 Industries...
  • Page 39 © Adafruit https://learn.adafruit.com/introducing-trinket Page 39 of 48 Industries...
  • Page 40: 16Mhz Vs 8Mhz Clock

    However, the AVR series is pretty forgiving for overclocking, so you may be able to run the 3V Trinket at 16 MHz. Note that this is still overclocking, your code may run flakey or not at all! Overclocking should not damage the AVR, but we still recommend sticking with 8 MHz only for the 3V version, and 8 or 16MHz only on the 5V version.
  • Page 41 © Adafruit https://learn.adafruit.com/introducing-trinket Page 41 of 48 Industries...
  • Page 42: Repairing Bootloader

    This loader isn't tested to work with any other kind of Arduino. Connect: Trinket VBAT+ pin to Arduino 5V (or just power it via a battery or USB cable) Trinket GND pin to Arduino GND Trinket RST to Arduino #10...
  • Page 43 © Adafruit https://learn.adafruit.com/introducing-trinket Page 43 of 48 Industries...
  • Page 44: Downloads

    Original code for the Trinket/Gemma bootloader on github (http://adafru.it/cE6) We do not offer any support for this code, it is released as-is! Please note: you cannot use the Adafruit USB VID/PID for your own non-Trinket/Gemma products or projects. Purchase a USB VID for yourself at http://www.usb.org/developers/vendor/ Schematics Trinket 3.3V Schematic:...
  • Page 45 Trinket 5V schematic © Adafruit https://learn.adafruit.com/introducing-trinket Page 45 of 48 Industries...
  • Page 46 © Adafruit https://learn.adafruit.com/introducing-trinket Page 46 of 48 Industries...
  • Page 47: Faq

    Trinket GND pin 3. Connect the data in line to Trinket #1 - this will let you also see when data is being sent because the #1 red LED will flicker. You can use other pins but start with #1...
  • Page 48 Why does Windows sound the Connect/Disconnect chimes every ten seconds? The Trinket only appears to be a USBtinyISP device when the bootloader is running. By design, the bootloader only runs for 10 seconds and then jumps back to the main user sketch.

Table of Contents