<< Summary

Read analog data from a joystick, in Java Raspberry PI

The goal here is to read analog data produced by a joystick from a Java program running on a Raspberry PI.
For this example, we will be using a joystick like this one.

We will reuse the setting of the ADC sample (using SPI bus). Instead of reading the potentiometer on one ADC channel, we will use the two analog channels (Up/Down and Left/Right) from the joystick. Those two outputs are - by the way - two potentiometers.
In addition, we will use those data from the joystick to drive two standard servos, as explained in the servo section.

Wiring

Click the diagram below to enlarge it.

Click to enlarge

5 Volts or 3.3 Volts power supply can be used the same way, it's OK with the Joystick, and the MCP3008. The I2C board driving the servos is happy with 3.3 Volts.
Interestingly, this example is using both SPI (for the MCP3008) and I2C (for the servo board).


Oliv did it