int xPin = A1; int yPin = A0; int buttonPin = 2; int buzzer = 9; int xPosition = 0; int yPosition = 0; int buttonState = 0; //define servos Servo servo1; Servo servo2; void setup() { // initialize serial communications at 9600 bps: Serial.begin(9600); pinMode(xPin, INPUT); pinMode(yPin, INPUT); pinMode(buzzer, OUTPUT); //activate pull-up resistor on the push-button pin pinMode(buttonPin, INPUT_PULLUP); // ******* S 13/ B 11/ G 12 / E 10 servo1.attach(13); servo2.attach(10); } void loop() { JoyStickControl(); } void JoyStickControl() { xPosition = analogRead(xPin); yPosition = analogRead(yPin); buttonState = digitalRead(buttonPin); // Servos xPosition = map(xPosition, 0, 1023, 0, 180); servo1.write(xPosition); yPosition = map(yPosition, 0, 1023, 0, 180); servo2.write(yPosition); if(buttonState ==0) { // you may control another servo motor tone(buzzer, 1000); // Send 1KHz sound signal... sound indicator for pressing noTone(buzzer); // Stop sound... } Serial.print("X: "); Serial.print(xPosition); Serial.print(" | Y: "); Serial.print(yPosition); Serial.print(" | Button: "); Serial.println(buttonState); delay(100); // add some delay between reads }