Feeling Dumb About Servos :/

Status
Not open for further replies.

lerxstrulz

Well-known member
Yesterday I posted a question about getting a PCA9685 working with Teensy 3.2 : https://forum.pjrc.com/threads/57819-Teensy-3-2-and-Adafruit-PCA9685

I decided to just pull the PCA9685 out of the equation for now and run the servos (there are only 4) directly. I had them working using the PWMServo library and using pins 3,4,5,6 and then all of a sudden they just stopped. I have replaced the Teensy 3.2 with another one thinking maybe I messed something up there, swapped out the servos, checked power (servos are powered externally from 6V) and connections with a meter. For debugging I am powering the Teensy through USB. I am NOT using VIN for power.

Thinking it might be something in my code I loaded up the sweep example that comes with Teensyduino, connected a single servo to pin 3 as before, powered by external 6V (checked with meter) pos and ground, signal wire continuity checked out with meter...and...nothing.

Is there some secret sauce? Something little I'm missing? Trying to figure out how it was all working before and now can't even get a simple demo sketch to work. Feeling a bit perplexed at this point :confused:

I also connected the ground of the servos to the Teensy ground according to https://www.pjrc.com/teensy/td_libs_Servo.html, but no luck.

Thoughts?

Thank you!

Just for reference, here is the simple sketch (this is for a continuous rotation servo):

Code:
#include <PWMServo.h>

PWMServo myservo;

void setup() {
  // put your setup code here, to run once:
 myservo.attach(3);
}

void loop() {
  // put your main code here, to run repeatedly:
  myservo.write(100);
}
 
I think there are a few more lines to the sweep example. This works great on the T 3.2 . Grounds connected?

Code:
#include <Servo.h> // another servo library github arduino
 
Servo myservo;  // create servo object to control a servo 
                // twelve servo objects can be created on most boards
 
int pos = 0;    // variable to store the servo position 
 
void setup() 
{ 
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object , or any other PWM Teensy pin
} 
 
void loop() 
{ 
  for(pos = 0; pos <= 180; pos += 1) // goes from 0 degrees to 180 degrees 
  {                                  // in steps of 1 degree (adjust so you don't bang the servo stop)
    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>=0; 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 
  } 
}
 
Status
Not open for further replies.
Back
Top