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 Adafruit_SoftServo library 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. 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.
Parts used:
- Adafruit Gemma M0, Trinket M0, Trinket Mini or Gemma v2 microcontroller board (if Trinket, either the 3.3V or 5V type works). We recommend using the Trinket M0.
- USB cable for power and reprogramming
- Standard 5 volt hobby servo (several are available in the Adafruit shop)
- Potentiometer (variable resistor), anything from 1K Ω to 10 KΩ, value not critical
- Breadboard, jumper wires/hookup wire
- Power supply and connector - if you want to have it connected to a battery pack or computer-independant
Text editor powered by tinymce.