Analog Joystick with two axes (horizontal/vertical) and an integrated push button.
|VCC||Positive power supply|
|VERT||Vertical axis output (analog)|
|HORZ||Horizontal axis output (analog)|
The idle position voltage is VCC/2. Moving the joystick along the vertical axis changes the voltage of the VERT pin from 0 volts (bottom) to VCC (top). Moving the joystick along the horizontal axis changes the voltages of the HORZ pin from 0 volts (right) to VCC (left).
The SEL pin is normally open (floating). Clicking on the center of the joystick shorts the SEL pin to ground. The joystick's button simulates bouncing by default. You can disable bouncing by setting the "bounce" attribute to "0".
|bounce||Set to "0" to disable bouncing||""|
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.
|Joystick Pin||Arduino Pins||Example code pin|
|VERT||any analog pin (A0...A5)||A0|
|HORZ||any analog pin (A0...A5)||A1|
|SEL||any digital pin||2|
To use the Joystick in Arduino, connect the VERT and the HORZ pins to analog pins (A0...A6), and configure these pins as input. Read the joystick position using
The following table shows the different joystick position and the corresponding HORZ / VERT values, as returned by
You can use the map() function to re-map the values to a different range.
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.
- Etch-a-sketch - A simple drawing game using a MAX7219 LED Dot Matrix