Using Teensy 3.2, and the pinout card (this one), I copy/pasted the Servo.h example from here, plugged in a servo (powered by a separate 5V supply) on pin 20, and uploaded and ran the code.
Literally nothing happens.
The Serial output is showing that the loop is executing ( I see the values being printed out), but other than that, nothing is happening. I've quadruple checked that I have the servo plugged into the correct pin. What am I doing wrong?
I've read somewhere that Teensyduino comes with it's own Servo library. How do I know whether I'm importing the correct one?
Code:
Literally nothing happens.
The Serial output is showing that the loop is executing ( I see the values being printed out), but other than that, nothing is happening. I've quadruple checked that I have the servo plugged into the correct pin. What am I doing wrong?
I've read somewhere that Teensyduino comes with it's own Servo library. How do I know whether I'm importing the correct one?
Code:
Code:
// Sweep
// by BARRAGAN <http://barraganstudio.com>
// from https://www.pjrc.com/teensy/td_libs_Servo.html
#include <Servo.h>
Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created
int pos = 0; // variable to store the servo position
void setup()
{
//Turn on the LED (basic power indicator)
pinMode(13,OUTPUT);
digitalWrite(13,HIGH);
// Initialize the serial port
Serial.begin(115200);
myservo.attach(20); // attaches the servo on pin 20
}
void loop()
{
for(pos = 10; pos < 170; pos += 1) // goes from 10 degrees to 170 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
Serial.println(pos);
}
for(pos = 10; pos>=170; 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
Serial.println(pos);
}
}
Last edited: