#include <Servo.h>
int x;
int y;
int servo_x;
int servo_y;
// DECLARAMOS LOS PINES QUE VAMOS A UTILIZAR
#define PIN_VRy A0
#define PIN_VRx A1
#define PIN_servo_x 5 // pin con PWM
#define PIN_servo_y 6 // pin con PWM
Servo motor_x;
Servo motor_y;
void setup() {
motor_x.attach(PIN_servo_x);
motor_y.attach(PIN_servo_y);
Serial.begin(9600);
}
void loop(){
x = analogRead(PIN_VRx);
y = analogRead(PIN_VRy);
servo_x = map( x, 0, 1023, 0, 180 );
servo_y = map( y, 0, 1023, 0, 180 );
motor_x.write( servo_x );
motor_y.write( servo_y );
Serial.println("X:" + String(x) + " - Y:" + String(y));
}