Day 01

Begineer

Day 16 :- Joystick Controlled Servo

Aug 21, 2026

Completed

Wiring Schematic

Arduino Code

ARDUINO / C++

Day 9 Core Training Documentation

Project Overview

The Joystick Controlled Servo project teaches you how to combine user input with mechanical control: using an analog joystick to move a Servo Motor in response to human commands.

In this project, an analog joystick provides directional input to Arduino, which then controls a Servo Motor position based on the joystick movement. Moving the joystick left positions the servo to the left, moving right positions the servo to the right, and returning to center positions the servo to the middle.

When the user moves the joystick, the Servo Motor responds instantly and smoothly, creating an interactive control system. This demonstrates how manual controllers interface with mechanical systems in real-world applications.

This project teaches Analog Input Reading, Joystick Operation, Input-to-Output Mapping, Servo Response Programming, and Interactive Control Systems.

By finishing this project, you’ll understand how control systems work in video game controllers, remote-controlled vehicles, camera movement systems, and industrial automation equipment.

Components Required

To build this circuit, collect these specific items from your kit:

Arduino Uno × 1, Breadboard × 1, Analog Joystick Module × 1, Servo Motor (SG90 or MG996R) × 1, Jumper Wires × 5, USB Cable × 1

Circuit Connections

Step 1: Connect Ground Rail

Connect the Arduino GND pin to the negative rail of the breadboard. This creates a shared ground connection for all components.

Step 2: Connect Joystick VCC

Connect the VCC (power) pin of the analog joystick module to Arduino 5V. This provides power to the joystick sensors.

Step 3: Connect Joystick GND

Connect the GND (ground) pin of the analog joystick module to the breadboard GND rail. This completes the power circuit for the joystick.

Step 4: Connect Joystick X-Axis

Connect the X-Axis output pin of the joystick to Arduino Pin A0. This analog pin reads the horizontal position of the joystick.

Step 5: Connect Joystick Y-Axis

Connect the Y-Axis output pin of the joystick to Arduino Pin A1. This analog pin reads the vertical position of the joystick.

Step 6: Connect Servo Motor Ground

Connect the brown (ground) wire of the Servo Motor to the breadboard GND rail. This provides the ground connection for the servo.

Step 7: Connect Servo Motor Power

Connect the red (power) wire of the Servo Motor directly to Arduino 5V. This supplies power to the Servo Motor.

Step 8: Connect Servo Motor Signal

Connect the orange (signal) wire of the Servo Motor to Arduino Pin 9. This receives the PWM positioning commands from the joystick input.

Step 9: Verify Connections

Double-check all joystick and servo connections before uploading your code. Ensure power and ground are correctly distributed to both components.

Important: The joystick analog values range from 0 to 1023, while servo angles range from 0 to 180 degrees. Your code must map these different ranges together for proper servo response.

How the Arduino Code Works

Read Joystick Input

In loop(), Arduino continuously reads the joystick X-axis value using analogRead(A0). This value ranges from 0 to 1023 depending on the joystick position.

Map Input to Servo Angle

The map() function converts the joystick reading (0-1023 range) to a servo angle (0-180 range). This mathematical conversion ensures that the full joystick movement corresponds to the full servo range.

Handle Center Position

When the joystick is at the center position, it reads approximately 512, which maps to 90 degrees on the servo. This centers the servo arm in its neutral position.

Move Servo to Target Position

The servo write() function is called with the mapped angle value. The servo instantly moves to the new position determined by the current joystick position.
 

Continuous Response Loop

The process repeats inside the loop() function many times per second. This provides smooth and responsive servo movement that follows the joystick input in real-time.

Expected Output

After uploading your code, here is what happens.

With the joystick in the center position, the servo arm positions itself in the middle at 90 degrees. Move the joystick toward the left and the servo smoothly rotates toward the 0-degree position. Move the joystick toward the right and the servo smoothly rotates toward the 180-degree position. Move the joystick rapidly and the servo follows with smooth continuous motion. Release the joystick and it returns to center, causing the servo to return to 90 degrees.

Operational Troubleshooting

Servo Does Not Respond to Joystick :- Verify that the X-axis pin connects to A0 and check that the servo signal wire connects to Pin 9. Confirm the Servo library is imported and the servo is properly initialized in setup().

Servo Response Is Backwards :- Modify the map() function to reverse the input range. Change the parameters from map(value, 0, 1023, 0, 180) to map(value, 1023, 0, 0, 180) to invert the response.

Servo Movement Is Jerky :- Increase the delay slightly in your loop to allow the servo time to process commands. Check that the joystick potentiometers are not worn or damaged causing inconsistent readings.

Joystick Does Not Respond :- Verify the VCC and GND connections to the joystick module. Check that the analog pins A0 and A1 are correctly connected to the X and Y axis outputs.

Servo Reaches Only Partial Range :- Verify the map() function is using 0 to 1023 for the input range. Check that the joystick is moving through its full range of motion and not mechanically limited.

What You Learned

By finishing this project, you now know :-

How analog joysticks work and provide directional input, how to read analog sensor values from multiple inputs, how to map data from one range to another, how to create responsive interactive control systems, and how to combine user input with mechanical control.

Next Lesson

In Day 17, you’ll learn how to use random number generation to create an electronic dice roller, displaying random numbers on a 7-segment display when a button is pressed.