Analog Joystick Interfacing with ARM MBED
Analog Joystick is an input device used to control the pointer movement in 2-Dimensional axes. Generally, joystick is used for getting angular movements.
2.3k views1 min readUpdated Jan 13, 2023
Overview of Analog Joystick

- Applications like video games that require a change in cursor position in a 2-D plane make use of analog joysticks as input devices.
- Analog joystick produces two voltages; one corresponding to the position with respect to X-axis and another corresponding to the position with respect to Y-axis. The voltages produced depend on the position of the joystick.
- For more information about Analog Joystick and how to use it, refer the topic Analog Joystick in the sensors and modules section.
To interface the Analog Joystick with MBED, we need to use ADC on the microcontroller of the ARM MBED board.
Connection Diagram of Analog joystick with ARM MBED (LPC1768)
Read X and Y directions of the Analog joystick using ARM MBED (LPC1768)
Displaying analog joystick voltages in X and Y directions on the serial monitor.
Here, we will be using the analog pins of MBED to process the analog voltages of the joystick.
Analog joystick Code for ARM MBED (LPC1768)
#include "mbed.h"
Serial pc(USBTX, USBRX); // tx, rx
AnalogIn analog_value_x(p15);
AnalogIn analog_value_y(p16);
int main() {
while(1){
pc.printf("X Value = %f\n\r", analog_value_x.read() * 3.3);
pc.printf("Y Value = %f\n\r", analog_value_y.read() * 3.3);
wait(0.5);
}
}
Output of Serial

Components Used
Powered by


Joystick is an input device used to control the pointer movement in 2-dimension axis. It is mostly used in Video games.
375-JOY-01
Downloads
Comments0
Join the discussion — share a question or tip.
Be the first to share your thoughts on this guide.