Hi guys,
I ordered a servo and I thought it would be fairly easy to use. I’ve tested out the two Arduino libraries, Servo.h and SoftwareServo.h. I followed Adafruit’s tutorial for Servo.h, and my servo only turns in one direction (left), and doesn’t stop even if it reaches the end. Here’s the code I have that tested both libraries. I don’t think I’m wiring it wrong, but maybe someone can help.
Servo.h
#include <Servo.h>
unsigned char servoPin = 9;
Servo servo;
void setup()
{
servo.attach(servoPin);
}
void loop()
{
servo.write(90);
delay(1000);
servo.write(0);
delay(1000);
servo.write(180);
delay(1000);
}
SoftwareServo.h
#include <SoftwareServo.h>
SoftwareServo servo;
void setup()
{
servo.attach(9);
}
void loop()
{
servo.write(0);
delay(1000);
SoftwareServo::refresh();
servo.write(90);
delay(1000);
SoftwareServo::refresh();
servo.write(180);
delay(1000);
SoftwareServo::refresh();
}