/*
  --------------- by JediRick -----------------
  boolean        (8 bit)   -  [true/false]
  byte           (8 bit)   -  [0-255] unsigned number
  char           (8 bit)   -  [-128 to 127] signed number
  unsigned char  (8 bit)   -  [-128 to 127] signed number
  word           (16 bit)  -  [0-65535] unsigned number
  unsigned int   (16 bit)  -  [0-65535] unsigned number
  int            (16 bit)  -  [-32768 to 32767] signed number
  unsigned long  (32 bit)  -  [0-4,294,967,295] unsigned number usually for millis
  long           (32 bit)  -  [-2,147,483,648 to 2,147,483,647] signed number
  float          (32 bit)  -  [-3.4028235E38 to 3.4028235E38] signed number
  uint8_t        (8 bit)   -  [0-255] unsigned number
  int8_t         (8 bit)   -  [-127 - 127] signed number
  uint16_t       (16 bit)  -  [0-65,535] unsigned number
  int16_t        (16 bit)  -  [-32,768 - 32,767] signed number
  uint32_t       (32 bit)  -  [0-4,294,967,295] unsigned number
  int32_t        (32 bit)  -  [-2,147,483,648 - 2,147,483,647] signed number
  uint64_t       (64 bit)  -  [0-18,446,744,073,709,551,615] unsigned number 
  int64_t        (64 bit)  -  [−9,223,372,036,854,775,808 - 9,223,372,036,854,775,807] signed number
  --------------------------------------------
*/
#include <Servo.h>
#define PIN_ANALOG_X 0    //Analog X
#define PIN_ANALOG_Y 1    //Analog Y
int maxAngle = 45;
int servoDelay = 100;
Servo myservo1, myservo2;  // create servo object to control a servo
void setup() {
  myservo1.attach(9);  // attaches the servo on pin 9 to the servo object
  myservo2.attach(10);  // attaches the servo on pin 9 to the servo object
}
void loop() {  
  mapAxis();
}
void mapAxis() {
  uint16_t  joyX = analogRead(PIN_ANALOG_X);
  uint16_t  joyY = analogRead(PIN_ANALOG_Y);  
  uint16_t  joyXmap = map(joyX, 0, 1023, 0, maxAngle);
  uint16_t  joyYmap = map(joyY, 0, 1023, 0, maxAngle);  
  myservo1.write(joyXmap);                  // sets the servo position according to the scaled value
  myservo2.write(joyYmap);                  // sets the servo position according to the scaled value
  delay(servoDelay);                           // waits for the servo to get there
}