#include <Servo.h> // include the Servo library
Servo myservo0; // create a servo object
Servo myservo1; // create a servo object
Servo myservo2; // create a servo object
Servo myservo3; // create a servo object
void setup() {
myservo0.attach(11); // attach the servo to pin 11
myservo1.attach(10);
myservo2.attach(9);
myservo3.attach(6);
Serial.begin(115200);
pinMode(A0, INPUT);
pinMode(A1, INPUT);
pinMode(A2, INPUT);
pinMode(A3, INPUT);
}
void loop() {
int value0 = analogRead(A0);
Serial.println(value0);
delay(100);
int rota0 = value0/5.72 ;
if(value0>0){
if(value0<1024){
myservo0.write(rota0); // set the servo to x degrees
}
}
int value1 = analogRead(A1);
Serial.println(value1);
delay(100);
int rota1 = value1/5.72 ;
if(value1>0){
if(value1<1024){
myservo1.write(rota1);
}
}
int value2 = analogRead(A2);
Serial.println(value2);
delay(100);
int rota2 = value2/5.72 ;
if(value2>0){
if(value2<1024){
myservo2.write(rota2);
}
}
int value3 = analogRead(A3);
Serial.println(value3);
delay(100);
int rota3 = value3/5.72 ;
if(value3>0){
if(value3<1024){
myservo3.write(rota3);
}
}
}