Controlling Multiple servo each with potentiometer_ Arduino:
Circuit:
Proteus Simulation:
#include <Servo.h>
// servo 1
Servo servo1;
const int servo1PotPin=A0;
const int servo1pin=3;
int servo1Value;
// servo 2
Servo servo2;
const int servo2PotPin =A1;
const int servo2pin=5;
int servo2Value;
void setup() {
servo1.attach(servo1pin);
servo2.attach(servo2pin);
}
void loop() {
servo1Value=analogRead(servo1PotPin);
servo1Value=map(servo1Value,0,1023,0,180);
servo1.write(servo1Value);
servo2Value=analogRead(servo2PotPin);
servo2Value=map(servo2Value,0,1023,0,180);
servo2.write(servo2Value);
delay(15);
}
Click On Links For code:
Click On Links For Proteus Simulation:
0 Comments