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.
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
Connect the Arduino GND pin to the negative rail of the breadboard. This creates a shared ground connection for all components.
Connect the VCC (power) pin of the analog joystick module to Arduino 5V. This provides power to the joystick sensors.
Connect the GND (ground) pin of the analog joystick module to the breadboard GND rail. This completes the power circuit for the joystick.
Connect the X-Axis output pin of the joystick to Arduino Pin A0. This analog pin reads the horizontal position of the joystick.
Connect the Y-Axis output pin of the joystick to Arduino Pin A1. This analog pin reads the vertical position of the joystick.
Connect the brown (ground) wire of the Servo Motor to the breadboard GND rail. This provides the ground connection for the servo.
Connect the red (power) wire of the Servo Motor directly to Arduino 5V. This supplies power to the Servo Motor.
Connect the orange (signal) wire of the Servo Motor to Arduino Pin 9. This receives the PWM positioning commands from the joystick input.
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.
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.
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.
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.
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.
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.
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.
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.
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.