Tutorial – TRINKET (and GEMMA) Servo Control!

Trinket Img 2161

Tutorial – TRINKET (and GEMMA) Servo Control! The Adafruit Trinket’s small size makes it ideal for lightweight or small projects including robotics. This project demonstrates the use of a standard hobby servo with the Trinket.

The standard Arduino IDE servo library will not work with 8 bit AVR microcontrollers like the ATTiny85 on the Trinket and Gemma due to differences in available timer hardware. Fortunately the SoftwareServo library, available at http://playground.arduino.cc/ComponentLib/Servo, works well on any available pin (a hardware PWM (pulse width modulated) pin is not required). The library is not ideal, in that servos must be refreshed periodically (see the Arduino site for an explanation). A true hardware library would be best if one could be coded, although it would be limited to pins capable of hardware PWM (GPIO #1 and #4).

If you turn the potentiometer, the servo will rotate from zero to 180 degrees. The circuit can be expanded into a number of useful projects.

Learn more!


Adafruit Products Trinket Clear Products 1500 Orig

Adafruit TRINKET – Mini MicrocontrollerTRINKET 3.3V and TRINKET 5.5V versions. 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. Perfect for when you don’t want to give up your expensive dev-board and you aren’t willing to take apart the project you worked so hard to design. It’s our lowest-cost arduino-IDE programmable board!

1500Bb Lrg

The Attiny85 is a fun processor because despite being so small, it has 8K of flash, and 5 I/O pins, including analog inputs and PWM ‘analog’ outputs. We designed a USB bootloader so you can plug it into any computer and reprogram it over a USB port just like an Arduino. In fact we even made some simple modifications to the Arduino IDE so that it works like a mini-Arduino board. You can’t stack a big shield on it but for many small & simple projects the Trinket will be your go-to platform.

1500Side Lrg

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. The 3V version should only run at 8 MHz. Use the 5V one for sensors and components that can use or require 5V logic. The 5V version can run at 8 MHz or at 16MHz by setting the software-set clock frequency.

Here are some useful specifications!

  • ATtiny85 on-board, 8K of flash, 512 byte of SRAM, 512 bytes of EEPROM
  • Internal oscillator runs at 8MHz, but can be doubled in software for 16MHz
  • USB bootloader with a nice LED indicator looks just like a USBtinyISP so you can program it with AVRdude (with a simple config modification) and/or the Arduino IDE (with a few simple config modifications)
  • Mini-USB jack for power and/or USB uploading, you can put it in a box or tape it up and use any USB cable for when you want to reprogram.
  • We really worked hard on the bootloader process to make it rugged and foolproof, this board wont up and die on you in the middle of a project!
  • ~5.25K bytes available for use (2.75K taken for the bootloader)
  • Available in both 3V and 5V flavors
  • On-board 3.3V or 5.0V power regulator with 150mA output capability and ultra-low dropout. Up to 16V input, reverse-polarity protection, thermal and current-limit protection.
  • Power with either USB or external output (such as a battery) – it’ll automatically switch over
  • On-board green power LED and red pin #1 LED
  • Reset button for entering the bootloader or restarting the program. No need to unplug/replug the board every time you want to reset or update!
  • 5 GPIO – 2 shared with the USB interface. The 3 independent IO pins have 1 analog input and 2 PWM output as well. The 2 shared IO pins have 2 more analog inputs and one more PWM output.
  • Hardware I2C / SPI capability for breakout & sensor interfacing.
  • Works with many basic Arduino libraries including Adafruit Neopixel!
  • Mounting holes! Yeah!
  • Really really small.
  • Dimensions: 1.2″ x 0.6″ x 0.2″ / 31mm x 15.5 x 5mm , 1.85 grams (no headers).

For a lot more details, including a tour of the Trinket, pinout details and Arduino IDE examples, check out the Introducing Trinket tutorial

You can get TRINKET 3.3V here and you can get TRINKET 5.5V. They’re each $7.95 !


Adafruit publishes a wide range of writing and video content, including interviews and reporting on the maker market and the wider technology world. Our standards page is intended as a guide to best practices that Adafruit uses, as well as an outline of the ethical standards Adafruit aspires to. While Adafruit is not an independent journalistic institution, Adafruit strives to be a fair, informative, and positive voice within the community – check it out here: adafruit.com/editorialstandards

Stop breadboarding and soldering – start making immediately! Adafruit’s Circuit Playground is jam-packed with LEDs, sensors, buttons, alligator clip pads and more. Build projects with Circuit Playground in a few minutes with the drag-and-drop MakeCode programming site, learn computer science using the CS Discoveries class on code.org, jump into CircuitPython to learn Python and hardware together, TinyGO, or even use the Arduino IDE. Circuit Playground Express is the newest and best Circuit Playground board, with support for CircuitPython, MakeCode, and Arduino. It has a powerful processor, 10 NeoPixels, mini speaker, InfraRed receive and transmit, two buttons, a switch, 14 alligator clip pads, and lots of sensors: capacitive touch, IR proximity, temperature, light, motion and sound. A whole wide world of electronics and coding is waiting for you, and it fits in the palm of your hand.

Have an amazing project to share? The Electronics Show and Tell is every Wednesday at 7:30pm ET! To join, head over to YouTube and check out the show’s live chat and our Discord!

Join us every Wednesday night at 8pm ET for Ask an Engineer!

Join over 38,000+ makers on Adafruit’s Discord channels and be part of the community! http://adafru.it/discord

CircuitPython – The easiest way to program microcontrollers – CircuitPython.org


New Products – Adafruit Industries – Makers, hackers, artists, designers and engineers! — JP’s Product Pick of the Week — 4pm Eastern TODAY! 11/12/24 @adafruit #adafruit #newproductpick

Python for Microcontrollers – Adafruit Daily — Python on Microcontrollers Newsletter: New Pi Goodies, Pico Powered Fallout T-45 Helmet and More! #CircuitPython #Python #micropython @ThePSF @Raspberry_Pi

EYE on NPI – Adafruit Daily — EYE on NPI Maxim’s Himalaya uSLIC Step-Down Power Module #EyeOnNPI @maximintegrated @digikey

Adafruit IoT Monthly — Halloween, WiLo, and more!

Maker Business – Adafruit Daily — First Solar’s $1.1 billion development of vertically integrated factory in the U.S.

Electronics – Adafruit Daily — Oscilloscope Jumble

Get the only spam-free daily newsletter about wearables, running a "maker business", electronic tips and more! Subscribe at AdafruitDaily.com !



No Comments

No comments yet.

Sorry, the comment form is closed at this time.