#include const byte leftPin = 2; const byte rightPin = 4; Servo pointer; int previousAngle = -1; void setup() { pinMode(leftPin, INPUT_PULLUP); pinMode(rightPin, INPUT_PULLUP); pointer.attach(9); pointer.write(90); } void loop() { const bool left = digitalRead(leftPin) == LOW; const bool right = digitalRead(rightPin) == LOW; const int angle = left == right ? 90 : (left ? 60 : 120); if (angle != previousAngle) { pointer.write(angle); previousAngle = angle; } delay(20); }