Teensy LC not compatible with modern digital servos?

I'm trying to resurrect a project from a couple of years ago. I was trying to use a motor and PID to control a lever, and gave up getting PID to work right.

Then someone suggested a servo. I bought a modern digital servo, but I note the LC is not supported by the latest servo code.

I tried several sketches using the old PWMServo, and I just get jitter from the servo.... is that code to old to work with modern servos? I do have the servo hooked up to pin 23, which is a PWM pin, right? I don't have to specify that's what I'm using it for, do I? I don't see that anywhere in sample code. I set the min and max based on my servo spec. Seems like this range is pretty standard these days.

Any thoughts?

Thanks,
-eric

Here's my code:
// Sweep
// by BARRAGAN <http://barraganstudio.com>
// http://arduiniana.org/libraries/pwmservo/
// Board SERVO_PIN_A SERVO_PIN_B SERVO_PIN_C
// ----- ----------- ----------- -----------
// Arduino Uno, Duemilanove 9 10 (none)
// Arduino Mega 11 12 13
// Sanguino 13 12 (none)
// Teensy 1.0 17 18 15
// Teensy 2.0 14 15 4
// Teensy++ 1.0 or 2.0 25 26 27
// Teensy LC & 3.x (all PWM pins are usable)
#include <PWMServo.h>
PWMServo myservo; // create servo object to control a servo
int pos = 0; // variable to store the servo position
void setup() {
myservo.attach(23,500,2500); // attaches the servo on pin 9 to the servo object
//myservo.attach(SERVO_PIN_A, 1000, 2000); // some motors need min/max setting
}

void loop() {
for(pos = 0; pos < 180; pos += 1) { // goes from 0 degrees to 180 degrees, 1 degree steps
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for(pos = 180; pos>=1; pos-=1) { // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
}
 
Back
Top