#include <Servo.h>
//Potenciómetros Pin
int PotenPin1 = A1;
int PotenPin2 = A2;
int PotenPin3 = A3;
int PotenPin4 = A4;
int PotenPin5 = A5;
//Potenciómetros Valor
int PotenVal1, PotenVal2, PotenVal3, PotenVal4, PotenVal5;
//Servomotores Pin
int ServoPin1 = 6;
int ServoPin2 = 2;
int ServoPin3 = 3;
int ServoPin4 = 4;
int ServoPin5 = 5;
//Servomotores Posición
int ServoPos1, ServoPos2, ServoPos3, ServoPos4, ServoPos5;
//Servomotores
Servo Servo1;
Servo Servo2;
Servo Servo3;
Servo Servo4;
Servo Servo5;
void setup()
{
//Potenciómetros Pin Mode
pinMode(PotenPin1, INPUT);
pinMode(PotenPin2, INPUT);
pinMode(PotenPin3, INPUT);
pinMode(PotenPin4, INPUT);
pinMode(PotenPin5, INPUT);
Servo1.attach(ServoPin1);
Servo2.attach(ServoPin2);
Servo3.attach(ServoPin3);
Servo4.attach(ServoPin4);
Servo5.attach(ServoPin5);
Serial.begin(9600);
}
void loop()
{
//Escribir el Ángulo del ServoMotor
Servo1.write(ServoPos1);
Servo2.write(ServoPos2);
Servo3.write(ServoPos3);
Servo4.write(ServoPos4);
Servo5.write(ServoPos5);
//Leer el Valor del Potenciómetro
PotenVal1 = analogRead(PotenPin1);
PotenVal1 = map(PotenVal1, 0, 1023, 0, 180);
PotenVal2 = analogRead(PotenPin2);
PotenVal2 = map(PotenVal2, 0, 1023, 0, 180);
PotenVal3 = analogRead(PotenPin3);
PotenVal3 = map(PotenVal3, 0, 1023, 0, 180);
PotenVal4 = analogRead(PotenPin4);
PotenVal4 = map(PotenVal4, 0, 1023, 0, 180);
PotenVal5 = analogRead(PotenPin5);
PotenVal5 = map(PotenVal5, 0, 1023, 0, 180);
//Adaptar la Posición del Servomotor al Voltaje del Potenciómetro
ServoPos1 = PotenVal1;
ServoPos2 = PotenVal2;
ServoPos3 = PotenVal3;
ServoPos4 = PotenVal4;
ServoPos5 = PotenVal5;
delay(0);
}