Pin names
Positive power supply
Vertical axis output (analog)
Horizontal axis output (analog)
Push button
Ground
Attributes
Set to “0” to disable bouncing
Operating the Joystick
You can operate the joystick with your mouse by moving cursor over the joystick. You’ll see four arrows, corresponding to the four movement directions, and a circle in the middle. Click on one of the arrows to move the joystick shaft in that direction, and on the circle in the middle to press the joystick’s push button (connected to the SEL pin). To operate the joystick with the keyboard, first focus on it (using the tab key or by clicking on it with the mouse), then use the arrow keys to move the shaft of the joystick, and the space key to press the joystick’s push button (connected to the SEL pin). It’s possible to combine multiple keys at once, e.g. left arrow and top arrow, to move the shaft in a diagonal direction. You can also press on the space key while holding down the arrows to press the joystick while moving the shaft.Partial movement and touch control are not currently supported. We’d love to see them supported though - so if you are up to the task, there’s an open issue waiting for your love.
Using the Joystick in Arduino
| Joystick Pin | Arduino Pins | Example code pin |
|---|---|---|
| VCC | 5V | |
| VERT | any analog pin (A0…A5) | A0 |
| HORZ | any analog pin (A0…A5) | A1 |
| SEL | any digital pin | 2 |
| GND | GND |
analogRead().
Joystick Position Table
The following table shows the different joystick position and the corresponding HORZ / VERT values, as returned byanalogRead():
| Position | HORZ | VERT |
|---|---|---|
| Top-Left | 1023 | 1023 |
| Top | 512 | 1023 |
| Top-Right | 0 | 1023 |
| Left | 1023 | 512 |
| Center | 512 | 512 |
| Right | 0 | 512 |
| Bottom-Left | 1023 | 0 |
| Bottom | 512 | 0 |
| Bottom-Right | 0 | 0 |
Using map()
You can use the map() function to re-map the values to a different range. For instance,map(analogRead(HORZ_PIN), 0, 1023, -100, 100) will return -100 when the joystick is all the way to the right, 0 when the joystick
in centered, and 100 when the joystick is all the way to the left.
Automation controls
The joystick can be controlled using Automation Scenarios. It exposes the following controls:Set the x value of the joystick (-1 to 1, 0 is centered)
Set the y value of the joystick (-1 to 1, 0 is centered)
Set to 1 to press the button, 0 to release it.
Simulator examples
- Etch-a-sketch - A simple drawing game using a MAX7219 LED Dot Matrix