Hi,
I have a question about my code to contol 2 servos with 1 button. I use code from the forum and I modify them to use 2 servos. The first servo work but not the second. I use external power for both. This is the code:
#include <Servo.h>
int button1 = 4; //button pin, connect to ground to move servo
int press1 = 0;
Servo servo1;
Servo servo2;
void setup()
{
pinMode(button1, INPUT);
servo1.attach(5);
servo1.attach(6);
digitalWrite(4, HIGH); //enable pullups to make pin high
}
void loop()
{
press1 = digitalRead(button1);
if (press1 == LOW)
{
servo1.write(160);
servo2.write(160);
}
else {
servo1.write(20);
servo2.write(20);
}
}
Regards
Philippe