Read the status of the joystick
Following are the values returned for the corresponding joystick positions:
0 - Not pressed
1 - Center
2 - Left
3 - Up
4 - Right
5 - Down
The above positions are with respect to the reference position of the Sense HAT. HDMI port of Raspberry Pi facing downwards is the reference position.
Read the position of the joystick.
ans = 1
The function returns the position of the joystick. In this example, it is assumed that you have pressed the joystick to the ‘center’ position.
You can find if the joystick is at the specified location. To check if the Joystick is at the position ‘up’, enter the following command.
The function returns ‘1’, if the Joystick is the specified position, in this example ‘up’.
mysh— Connection to SenseHAT
Connection to a SenseHAT board, specified as a sensehat object.
joystickPress— Position of the joystick
This argument returns the position of the joystick pressed (value between 0 to 5) or returns
‘1’ if the specified joystick position is pressed. The value is returned in