Review and Going Further

How It Works

The potentiometer creates a voltage divider, providing a voltage from zero to five volts depending on how you turn the shaft. The voltage is read by the analog input on the Trinket. The Trinket calculates an angle from zero to 180 degrees in proportion to the voltage on the potentiometer. The Adafruit_SoftServo library sends a pulse width modulated signal to the Trinket Pin 0, which is interpreted by the servo as a specific angle to move to depending on the pulse width.

The Adafruit_SoftServo Library

You may define multiple Adafruit_SoftServo objects and control them on different pins. In theory, all five pins should be capable or servo use, but if using #3 and #4 remove the servo(s) while USB uploading!

The trickiest part of using this library is the constant software refresh to keep signals going to the servos. We take advantage of the Arduino IDE's built in timer (commonly known as millis()) and piggyback on top of it to create the 50-times-a-second update a servo requires.

As previously stated, it would be preferable to have an AVR 8 bit hardware timer based library. One on the web, Servo8Bit, is billed as ATtiny85 compatible.  

Going Further

Two servos can create an x-y axis controller or a two wheeled robot. This would still leave 3 pins for other functions.

This guide was first published on Sep 12, 2013. It was last updated on Sep 12, 2013.
This page (Review and Going Further) was last updated on Jul 04, 2020.