#include<Servo.h>
Servo servoA, servoB;
int x=A0, y=A1, sw=2;
int a=3, b=4, c=5, d=6;
int nilaiX, nilaiY, nilaiSwitch;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
servoA.attach(8);
servoB.attach(9);
servoA.write(0);
servoB.write(0);
pinMode(sw, INPUT_PULLUP);
pinMode(x, INPUT);
pinMode(y, INPUT);
pinMode(10, OUTPUT);
pinMode(11, INPUT);
pinMode(12, INPUT_PULLUP);
}
void loop() {
// put your main code here, to run repeatedly:
if(digitalRead(12) == 0){
digitalWrite(10, HIGH);
tone(11, 1000);
} else {
digitalWrite(10, LOW);
noTone(11);
}
nilaiX = map (analogRead(x), 0,1023,0,180);
nilaiY = map (analogRead(y), 0,1023,0,180);
nilaiSwitch = digitalRead(sw);
servoA.write(nilaiX);
servoB.write(nilaiY);
Serial.println(nilaiSwitch);
}