Analog Joystick Interfacing with ARM MBED

Overview of Analog Joystick

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)

Interfacing Analog Joystick Module with ARM MBED

 

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

ARM mbed 1768 LPC1768 Board
ARM mbed 1768 Board
1
Analog Joystick
Joystick is an input device used to control the pointer movement in 2-dimension axis. It is mostly used in Video games.
1

Downloads

analog_joystic_mbed_uvision5_lpc1768 Download
Ad