This lesson introduces the joystick. |
|
A joystick is an input device that allows the user to enter directional information--up, down, left, right--by moving the joystick in the intended direction. Many joysticks also can work as a button by pressing down on it. Joysticks and similar devices are often used in video game controllers. We will learn how to use a joystick to control an LED and move a Linkbot robot in the activities that follow this lesson.
2. The Joystick's Pins The joystick has five pins: Y, X, B, VCC, and GND.
3. Connecting the Joystick to an Arduino Board
1. Use male-to-female wires to connect the VCC and GND pins to the 5V pin and one of the GND pins, respectively, in the Power section of the Arduino. 2. Connect the B (button) pin to digital pin 2 on the Arduino. 3. Connect the Y pin to analog pin A0. 4. Connect the X pin to analog pin A1. 4. Joystick Pin Values Note that the joystick button (B) is connected to a digital pin on the Arduino, because the button is either on (pushed down) or off (HIGH voltage when on, LOW voltage when off). But the Y and X pins are connected to analog pins, because the joystick covers a range of values as it is moved forward and backward, or left and right.
|
joystick
|
Click the Run button to view and answer some questions about this lesson. |
Grid Lines: | ||
Tics Lines: |
|
Width
px
|
Hash Lines: |
|
Width
px
|
Labels: |
|
Font
px
|
Trace Lines: | ||
Robot 1: |
|
Width
px
|
Robot 2: |
|
Width
px
|
Robot 3: |
|
Width
px
|
Robot 4: |
|
Width
px
|
Grid Size: S M L | Simple View: | MinView: |
![]() |
|
Coord: x-axis y-axis | Grid Lines: x-axis y-axis | |||
Grid: | 12x12 inches | 24x24 inches | 36x36 inches | |
72x72 inches | 96x96 inches | 192x192 inches | ||
1x1 inches | 2x2 inches | Fraction: | ||
xy-Range: | ||||
|
||||
|
||||
Quad: | 1 Quadrant | 4 Quadrants | 1&4 Quadrants | |
Units: | US Customary | Metric | Ruler: | |
Label: |
|
|
|
|
|
|
|
|
|
|
|
|||||||||||
|
|||||||||||