MyRoboPathOpen Robotics Lab
Arduino Uno #26 of 35
Est. 0.5 Hours
Budget: $2 - $4
Beginner

Dual-Axis XY Analog Joystick & Center-Deadzone Gimbal

Read proportional 2D thumbstick coordinates (VRx/VRy) plus integrated push switch to steer servos, games, and rovers.

Master proportional human-robot teleoperation with the KY-023 dual-axis analog joystick module. Sample two orthogonal 10kΩ potentiometers on A0 and A1, apply center deadzone filtering around (512, 512), normalize output to -100%..+100%, and detect shaft clicks on D2.

Arduino Uno R3KY-023 JoystickDual ADC (A0/A1)Deadzone FilteringTeleop Control
Dual-Axis XY Analog Joystick & Center-Deadzone Gimbal Blueprint
Dual-Axis XY Analog Joystick & Center-Deadzone GimbalCAD Blueprint

Key Learning Objectives & Robotics Concepts

By building and programming this project, you will master the following core engineering skills:

1Understand how a 2-axis gimbal links thumbstick tilt to two perpendicular 10kΩ voltage dividers.
2Capture resting center offsets at boot so imperfect springs never cause phantom robot drift.
3Implement a symmetric deadzone filter and clean -100 to +100 percentage normalization.
4Read the integrated shaft click switch with INPUT_PULLUP for mode toggling.

Power Architecture & Voltage Staging

5V / 3.3V Regulated Power

Powered directly from Arduino Uno 5V and GND (<1.5mA across the two 10kΩ potentiometers). Centering springs hold VRx and VRy near 2.5V (~512 ADC) when released. Two 10kΩ potentiometers draw only 1mA total from 5V; always enable INPUT_PULLUP on SW (D2) since module switch pulls to GND.

Dual-Axis XY Analog Joystick & Center-Deadzone Gimbal Power Architecture Schematic
Figure: Regulated Arduino Uno supply rails, current budget, and component protection.Power Schematic

Bill of Materials (BOM) & Hardware Components

Bill of Materials for Dual-Axis XY Analog Joystick & Center-Deadzone Gimbal
ComponentSpecifications & AlternativeQtyApprox Cost
Arduino Uno R3ATmega328P @ 16MHz1$8.00
KY-023 Dual-Axis Analog Joystick2× 10kΩ gimbal pots + tactile center button1$1.80
5× Male-to-Female Jumper WiresVCC, GND, VRx, VRy, SW leads5$0.50

Electrical & System Architecture

Connect Joystick +5V to 5V, GND to GND, VRx to A0, VRy to A1, and SW (push button) to D2 (configured as INPUT_PULLUP).

Figure: Complete Arduino Uno R3 pin-to-pin wiring schematic for Dual-Axis XY Analog Joystick & Center-Deadzone Gimbal.
Figure: Complete Arduino Uno R3 pin-to-pin wiring schematic for Dual-Axis XY Analog Joystick & Center-Deadzone Gimbal.Wiring Schematic

Autonomous Behavior & Finite State Machine (FSM)

Deterministic Arduino loop handling KY-023 Dual-Axis XY Thumbstick Module acquisition, filtering, and real-time output updates.

Figure: Firmware execution flow and state transitions for Dual-Axis XY Analog Joystick & Center-Deadzone Gimbal.
Figure: Firmware execution flow and state transitions for Dual-Axis XY Analog Joystick & Center-Deadzone Gimbal.Control Algorithm

Step-by-Step Physical Assembly & Wiring Tutorial

Follow each of the 5 sequential milestone stages with technical photos, wiring checks, and pre-flight tests.

1

Inspect KY-023 5-Pin Header & Gimbal Cap

Duration: 5 Mins

Snap the black thumb cap onto the joystick post and inspect the 5 labeled pins.

Dual-Axis XY Analog Joystick & Center-Deadzone Gimbal hardware layout diagram
Stage 1: KY-023 Dual-Axis XY Thumbstick Module hardware inspection & pinout overview.Stage 1 Diagram
Step Action Checklist:
  • Verify header labels: GND, +5V, VRx, VRy, SW.
  • Press straight down on the thumb cap to hear the tactile click of the SW button.
  • Release the stick before powering on so auto-centering captures true neutral.
Engineering & Tuning Tip: Many joysticks rest at (504, 519) instead of exact (512, 512)—capturing center at boot makes deadzone math rock-solid!
2

Wire VRx→A0, VRy→A1 & SW→D2

Duration: 5 Mins

Connect all five joystick leads directly to the Arduino Uno.

Dual-Axis XY Analog Joystick & Center-Deadzone Gimbal breadboard wiring check diagram
Stage 2: Breadboard layout & Arduino Uno pin-to-pin wiring audit.Stage 2 Diagram
Step Action Checklist:
  • Wire +5V → Arduino 5V and GND → Arduino GND.
  • Wire VRx → A0, VRy → A1, and SW → D2.
  • Verify SW pin is configured as INPUT_PULLUP in software.
Engineering & Tuning Tip: No breadboard is even required when using Male-to-Female jumpers!
3

Verify Full-Deflection Endpoints

Duration: 5 Mins

Run the raw diagnostic to check X/Y extremes (0 to 1023) and click response.

Dual-Axis XY Analog Joystick & Center-Deadzone Gimbal power rail protection diagram
Stage 3: Supply rail check (USB 5.0V Regulated Rail (<2mA)) and circuit protection verification.Stage 3 Diagram
Step Action Checklist:
  • Upload the diagnostic snippet and open Serial Monitor.
  • Push stick full Left/Right and Up/Down to confirm clean 0↔1023 swings.
  • Press straight down on the stick and verify SW drops to 0.
Engineering & Tuning Tip: Notice which physical direction corresponds to X+ and Y+ based on how you hold the PCB.
4

Upload Normalized Deadzone Vector Firmware

Duration: 10 Mins

Flash the calibrated teleoperation controller producing clean -100..+100 axes.

Dual-Axis XY Analog Joystick & Center-Deadzone Gimbal serial telemetry verification diagram
Stage 4: Firmware upload & 115200 baud Serial Monitor verification.Stage 4 Diagram
Step Action Checklist:
  • Upload the production sketch below without touching the stick during boot.
  • Confirm resting output reads cleanly: X=0%, Y=0% (CENTER).
  • Move stick in circles and watch smooth percentage vectors and 8-way directions stream live.
Engineering & Tuning Tip: Normalized -100..+100 vectors drop straight into servo pan-tilt or 2WD differential rover motor mixers!
5

Test Diagonal & Click Combinations

Duration: 5 Mins

Confirm diagonal moves report combined X/Y percentages and center click registers reliably.

Dual-Axis XY Analog Joystick & Center-Deadzone Gimbal live operational logic diagram
Stage 5: Live operational logic flow & calibration verification.Stage 5 Diagram
Step Action Checklist:
  • Hold stick at North-East diagonal and observe both X and Y positive.
  • Click the shaft button while centered and while tilted.
  • Release stick and verify instant return to exact 0%.
Engineering & Tuning Tip: Always keep a ±5–8% deadzone in robotic controllers so motors never buzz quietly when you let go of the stick.

Subsystem Benchtop Verification Scripts

Test each hardware subsystem independently before deploying the full autonomous firmware.

1Bench Diagnostic: KY-023 Dual-Axis XY Thumbstick Module Hardware Check

Subsystem Diagnostic

Minimal standalone sketch to verify pin wiring and signal response for KY-023 Dual-Axis XY Thumbstick Module before running the full project firmware.

Arduino IDE Diagnostic ScriptC++ / Arduino
// Diagnostic: Raw Dual-Axis Joystick Monitor
void setup() { pinMode(2, INPUT_PULLUP); Serial.begin(115200); }
void loop() {
  Serial.print("X:"); Serial.print(analogRead(A0));
  Serial.print(" Y:"); Serial.print(analogRead(A1));
  Serial.print(" SW:"); Serial.println(digitalRead(2) == LOW ? "CLICK" : "UP");
  delay(150);
}
Expected Output: X:511 Y:508 SW:UP at rest; swings 0..1023 on tilt and CLICK when pressed.

Complete Production Firmware

Full working C++ source code with pin mappings, non-blocking timers, and FSM avoidance routines.

arduino_uno_dual_axis_analog_joystick.ino
arduino_uno_dual_axis_analog_joystick.inoArduino C++
/**
 * Project 26: KY-023 Dual-Axis Analog Joystick with Deadzone Normalization
 * Board: Arduino Uno R3 | Pins: A0 (VRx), A1 (VRy), D2 (SW)
 */
const uint8_t PIN_VRX = A0;
const uint8_t PIN_VRY = A1;
const uint8_t PIN_SW  = 2;
const int DEADZONE_ADC = 35;

int centerX = 512, centerY = 512;

int normalizeAxis(int raw, int center) {
  int diff = raw - center;
  if (abs(diff) <= DEADZONE_ADC) return 0;
  if (diff > 0) return constrain(map(diff, DEADZONE_ADC, 1023 - center, 1, 100), 0, 100);
  return constrain(map(diff, -DEADZONE_ADC, -center, -1, -100), -100, 0);
}

void setup() {
  Serial.begin(115200);
  pinMode(PIN_SW, INPUT_PULLUP);
  delay(150);
  centerX = analogRead(PIN_VRX);
  centerY = analogRead(PIN_VRY);
  Serial.print(F("Joystick Calibrated Center=("));
  Serial.print(centerX); Serial.print(','); Serial.print(centerY); Serial.println(')');
}

void loop() {
  int xPct = normalizeAxis(analogRead(PIN_VRX), centerX);
  int yPct = -normalizeAxis(analogRead(PIN_VRY), centerY); // Up = Positive
  bool pressed = (digitalRead(PIN_SW) == LOW);

  Serial.print(F("X: ")); Serial.print(xPct);
  Serial.print(F("% | Y: ")); Serial.print(yPct);
  Serial.print(F("% | Btn: ")); Serial.print(pressed ? F("PRESSED") : F("UP"));
  Serial.print(F(" | Dir: "));

  if (xPct == 0 && yPct == 0) Serial.println(F("CENTER"));
  else if (abs(yPct) >= abs(xPct)) Serial.println(yPct > 0 ? F("UP") : F("DOWN"));
  else Serial.println(xPct > 0 ? F("RIGHT") : F("LEFT"));

  delay(120);
}

Firmware Architecture Explanation:

  • Auto-captures mechanical spring rest points (centerX, centerY) during setup().
  • Applies a ±35 ADC deadzone and smoothly rescales remaining travel into -100..+100%.
  • Inverts Y so pushing "up" yields intuitive positive values for games and servos.

Operational Verification & Pin State Matrix

1Double-check all 4 Arduino Uno pin connections against the wiring schematic before plugging in USB.
2Upload the Bench Diagnostic sketch first and confirm Serial Monitor at 115200 baud matches: X:511 Y:508 SW:UP at rest; swings 0..1023 on tilt and CLICK when pressed.
3Upload the complete production sketch and verify every condition in the operational truth table below.

Input Signal vs. System Output Truth Table:

Operational truth table for Dual-Axis XY Analog Joystick & Center-Deadzone Gimbal
Input / StatePin / SignalDetected ConditionExpected Output
Stick CenteredA0≈512, A1≈512Within DeadzoneX=0%, Y=0% (CENTER)
Full RightA0≈1023Max X DeflectionX=+100% (RIGHT)
Shaft ClickedD2 = LOWButton ActiveBtn: PRESSED

Engineering Troubleshooting Matrix

Engineering troubleshooting matrix for Dual-Axis XY Analog Joystick & Center-Deadzone Gimbal
ProblemLikely CauseDiagnostic CheckEngineering Solution
Resting X or Y drifts at ±4% even untouchedLoose gimbal spring exceeding 35 ADC deadzoneObserve raw center wobbleIncrease DEADZONE_ADC from 35 to 50.
SW always reads PRESSED or floats randomlyMissing INPUT_PULLUP on D2Verify pinMode(PIN_SW, INPUT_PULLUP)Enable internal pull-up resistor on D2.
Up/Down feels invertedModule held rotated 180° relative to code signPush up and check Y signRemove the minus sign before normalizeAxis on Y.

Engineering Challenges & Upgrades

Take your build to the next level with these progressive engineering upgrades:

Level 1Pan-Tilt Dual Servo Turret

Map X and Y directly to two SG90 servos (Project 8) for a miniature camera gimbal.

Level 24-LED Directional Compass

Light North, South, East, West LEDs with PWM brightness proportional to stick tilt.

Level 3OLED Crosshair Radar

Render a live moving crosshair cursor on Project 4 SSD1306 OLED.