/*
 * ATtiny85 Joystick Servo Control
 *   xAxis - PB2 (A1)
 *   yAxis - PB4 (A2)
 *   servoX - PB1 (1)
 *   servoY - PB0 (0)
 */
#include <Servo.h>
#define xAxis 2
#define yAxis 4
#define xServoPin 1
#define yServoPin 0
Servo xServo;
Servo yServo;
int xIn;
int yIn;
int xOut;
int yOut;
void setup() {
  // put your setup code here, to run once:
  xServo.attach(xServoPin);
  yServo.attach(yServoPin);
}
void loop() {
  // read joystick position
  xIn = analogRead(xAxis);
  yIn = analogRead(yAxis);
  // map joystick values to desired servo angle
  xOut = map(xIn, 0, 1023, 75, 105);  // 15 deg swing each way in x-direction
  yOut = map(yIn, 0, 1023, 75, 105);  // 15 deg swing each way in y-direction
  // send to servos
  xServo.write(xOut);
  yServo.write(yOut);
  delay(15);
}