
It is a 5-direction joystick, which is able to detect the value of x- and y-xis (4 directions), and the pressing of the z-axis. It is a special I2C module. The pin holes on the back allow compatibility with plastic building blocks.
Parameter
Size |
24 x 24 x 23 mm |
Weight |
7 g |
Type |
I2C |
Range |
X:-255~255 Y:-255~255 Z: Pressed or not |
Wiring
Connect the joystick module to the blue I2C interface of the Robotbit Edu with a 4-pin cable.
When Robotbit is on, you can see that the red light on the bottom of the Light sensor module is on too, which means that the module is normally powered.
Programming
■ Effect
Print the data of the x- and y-axis on the Future board screen. When the joystick is pressed, "Pressed" would appear on the third line of the screen.
■ Use Kittenblock
Use the "Join" block in the Operators section to concatenate strings together (numbers will be changed into strings).
Due to the poor real-time performance of online interaction, it is recommended to upload the program to the Future board to run.
Note: The colon in the block that shows the English string must be an English colon (do not enter it under the Chinese input method)
■ Use MicroPython
Joystick Direction Value
value(dir)
- dir: Choose the direction
- "x": x-axis, the range of the return value -255~255
- "y": y-axis, the range of the return value -255~255
state()
- Return value:
- By default: "none"
- Other status: detect the status of 5 directions, return "pressed", "left", "right", "up", or "down" according to the status triggered.
