The joystick is similar to a game console controller. Each button can be moved in any direction. By pressing the joystick down, an additional button can be used. This way vehicles and robots can be controlled or even own games can be played.
Two signals are received via pins C16 and C17. C16 represents the values of the X-axis and C17 the values of the Y-axis.

Further information to the sensor you will find here.
Joystick can be ordered here.

port: A1
interface: analog
output values

X/Y approx. 200 - 800
pressed: 1023


The "Joystick" blocks are included in the Grove package. Again, there are two ways to read out the values of the joystick.
Either a continuous loop is used and the joystick directions are read and compared in an if-then condition or the event block "if Grove - joystick direction x" is used.

video hex

Open Roberta Lab

Two sensors must be created in the robot configuration. The sensor for the X-value at C16 and the sensor for the Y-value at C17.
Since there is no library for the directions of the joystick, the sensor values must either be interpreted by the robot itself or assigned to a separate value range.
If the joystick is positioned in the middle, the X and Y values are in a range of about 500-520. If the joystick is pointed upwards (depending on the perspective from which it is viewed), the X value increases and goes up to a maximum of 800. If it is pointed downwards, the value goes down to a minimum of 200. The same applies to the Y value to the left and right.
The pressing of the key can be queried by comparing in the if/then condition whether the value corresponds to the maximum analog value of 1023. The complete program can be found in the XML file.