#include <Servo.h>
Servo servoX;
Servo servoY;
int input = 0;
int x = 90;
int y = 90;
int one_step = 5;
void setup () {
servoX. attach (9);
servoY. attach (10);
servoX. write (x);
servoY. write (y);
Serial.begin (9600);
}
void loop () {
if (Serial. available ()> 0) {
input = Serial.read ();
// UP
if (input == 56 && y <180) {
y = y + one_step;
servoY.write (y);
}
// DOWN
if (input == 50 && y> 0) {
y = y - one_step;
servoY.write (y);
}
// LEFT
if (input == 52 && x <180) {
x = x + one_step;
servoX.write (x);
}
// RIGHT
if (input == 54 && x> 0) {
x = x - one_step;
servoX.write (x);
}
}
}