Using Analog Joystick From 37 Sensors Kit
Using Analog Joystick From 37 Sensors Kit
by indestructable
So you went out and bought a kit of electrical sensors experimentation and education.
and modules for a good price called "37 Sensors" (
like this one here or others on Amazon), but can't find The module from the 37 Sensors Kit called "Analog
information on the modules to be able to use them? Joystick" is a joystick module like the one found on
This series of Instructables will help you out with all of many game controllers. The Analog Joystick module
the modules in the 37 Sensors Kit. There are other might be used in an embedded project for man-
kits that sell a different number of modules than 37, machine interfacing such as controlling a robot
such as a 20 module kit, and a 45 module kit. These actuator, drawing onto an LCD display, quad-copter
sensors/modules are also available from some online control, and playing computer games.
stores individually.
(Images and information used with permission from
These kits are excellent for STEM (Science, 37sensors.com)
Technology, Engineering, and Mathematics)
The Analog Joystick module is made from two output in that represents both the X and Y position of
potentiometers that are set at right angles to each the two potentiometers. There is a spring in each
other. One potentiometer registers movement in the X potentiometer that centers the potentiometer. Thus
direction, the other potentiometer registers movement the joystick stays in the middle position when it is not
in the Y direction. touched.
The module needs a ground and power connection to Pushing the knob down engages a momentary
whatever microcontroller you might be interfacing. switch. This Z direction signal isn't analog but instead
Voltage can be 5V or 3.3V as with the typical is a digital output. The Z output of the module can be
microcontroller. read by a digital input to the microcontroller.
Voltage: 3.3V to 5.0V (No active components with function, voltage levels, pinout, and inactive/active
voltage limits, so using other voltages are possible.) states. Some modules have been found to have
incorrectly labeled pins and even poorly soldered
LED: none components.
1. Pinouts
Download
http://www.instructables.com/ORIG/F54/QFAW/JJIUBH8D/F54QFAWJJIUBH8D.pdf
…
Just to see the basics of how this module works, this experiment shows how to interface it to a simple-to-
understand microcontroller board. This microcontroller board is a $12.99 kit that can be assembled easily. There is
no need for a complicated development system as the 32-bit micro that is part of this board has all of the smarts
built in. The board shape even allows it to be used with Arduino Shields.
Code for other microcontroller platforms would likely be in a different language/syntax, but similar in form.
1. Analog Joystick from 37 Sensors Kit. (This experiment's source: CircuitGizmos) Kits also
available at Amazon and online in many places.
2. Jumper Wires, female to female "DuPont" style. (This experiment's source: CircuitGizmos)
Jumpers of this type are also available online.
3. Microcontroller Board. (This experiment's source: CircuitGizmos for the $12.99 kit. An assembled
board of a more capable but similar device is also available.)
4. Power supply. The board accepts 7-10VDC through barrel jack or 5V/3.3V through the connector.
5. USB serial Interface. A USB connection to a PC and 3.3V level connection for ground, transmit,
and receive for the board.
A PC with a serial terminal application is used to communicate with the board. One such free and useful program
is Beagle Term.
With all of this, you can perform an experiment to test the Analog Joystick.
Connect the USB serial interface to the PC (USB end) and to the serial signal connection of the microcontroller
board (near the green power LED). The ground connections between the serial interface and the board connect
together, and the transmit signal of one goes to the receive signal of the other.
Power up the microcontroller board. I used a 12VDC supply that worked just fine.
Start Beagle Term on the PC and connect to the serial port number that is appropriate for the USB serial interface.
Bitrate needs to be 38400, 8N1 with no flow control. Tap the enter key and you should get a ">" prompt.
With the PC connected to a powered microcontroller board, Beagle Term is the window into what is happening on
that board. You can enter program code, see the printed results of that code, and even interact by typing
information into a running program.
Typing EDIT at the ">" prompt will connect you to the built-in editor. It is in this editor that you will enter the
program code. You can save the code that you type in with a Control-Q keystroke. You can save and immediately
run the code that is in the editor with Control-W.
Control keys for the program EDIT function. (Function keys don't work right in Beagle Term)
DO
PAUSE 200
S = PIN(6)
X = PIN(4)
Y = PIN(5)
PRINT S, X, Y
LOOP
This code sets the signal lines to analog inputs for X and Y and a digital input for the switch. The digital input is
configured with an internal pull-up resistor.
The loop code then reads those inputs and prints them out to the console every 1/5th of a second.
If you run this code you will see the output sent to Beagle Term. That output will change as you move the joystick
around. The switch output will change when you depress the joystick knob.
The S variable is digital, so the PRINT statement will display either a 1 for unpressed or a 0 for pressed.
The X and Y variables are analog and will display values from 0V to 3.3V.
With the joystick not moved from the center position, both X and Y are at around 1.65V.
Microphone Speaker
Photoresistor Tracking
Pulse
Reed Switch