If (sw1ButtonState != lastsw1ButtonState) MyServo1.write(90) // Tell servo to go to position per quirkĭelay(15) // Wait 15ms for the servo to reach the position MyServo1.attach(SERVO1PIN) // Attach the servo to pin 0 on Trinket TIMSK |= _BV(OCIE0A) // Turn on the compare interrupt (below!) Set up the interrupt that will refresh the servo for us automagically #define SERVO1PIN 0 // Servo control line (orange) on Trinket Pin #0Īdafruit_SoftServo myServo1, myServo2 //create TWO servo objects #include // SoftwareServo (works on non PWM pins)
Required hardware includes an Adafruit Trinket microcontrollerĪ servo motor, and a potentiometer (nominally 1Kohm to 100KohmĪs written, this is specifically for the Trinket although it shouldīe Gemma or other boards (Arduino Uno, etc.) with proper pin mappingsĬonnection: Servo+ - Servo1 Potentiometer wiper We simply refreshīy piggy-backing on the timer0 millis() counter In available timer hardware and programming.
The standard Arduino IDE servo library will not work with 8 bitĪVR microcontrollers like Trinket and Gemma due to differences Required library is the Adafruit_SoftServo library To set the corresponding position on the servo
#Adafruit trinket setup code#
The code you posted doesn’t compile (doesn’t even have a loop() function)… If you have code that makes the servos twitch, you’ve gotten further than that, and you should post that code (preferably using code tags.) /*******************************************************************