I am trying to use the Arduino to turn on a servo, move it to a position, then turn the servo back off. I need the servo to be turned off because of power consumption issues among other reasons.
Here is my code
#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
int Servo = 5; // Servo power connected to pin 5
void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
pinMode(Servo, OUTPUT); // Set a digital pin for the GPS Power
}
void loop()
{
digitalWrite(Servo, HIGH); // Turn the Servo on
myservo.write(10); // tell servo to go to position
digitalWrite(Servo, LOW); // Turn the Servo off
delay(1000);
digitalWrite(Servo, HIGH); // Turn the servo on
myservo.write(105); // tell servo to go to position
delay(1000);
digitalWrite(Servo, LOW); // Turn the Servo off
}
It works when I have the power line connected to the 5v pin on the Arduino however it will not work when it is plugged into pin 5 (or any other pin I set it to for that matter)
I use this same method successfully to power a GPS unit. Any ideas on why it will not work?
I thought maybe adding delays after the servo high and before the servo low might help but it does not.
Pin 5 reads 4.75v
5v Pin reads 4.80v