Hi, Ive recently started a new arduino project. I want to control two servos manually using two potentiometers(10k). I have an arduino uno. I based the code off one of the servo example codes already in the software(knob). The servos seems to work fine individually. The problem starts when i connect them both and try to control the servos. The board "on" light starts to flicker as if its losing power. The servos eventually become weaker. Is my code off or am I just not wiring up my system correctly? The wiring seems pretty straightforward. Suggestions would be appreciated. You can see my code below.
#include <Servo.h>
Servo myservo; // create servo object to control a servo
Servo mysecondservo;
int potpin = A0; // analog pin used to connect the potentiometer
int potpin2= A5;
int val; // variable to read the value from the analog pin
int val2;
void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
mysecondservo.attach(7);
}
void loop()
{
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
myservo.write(val);
val2 =analogRead(potpin2);
val2 =map(val2,0, 1023, 0, 179); // sets the servo position according to the scaled value
mysecondservo.write(val2);
delay(15); // waits for the servo to get there
}