Today we examine an inexpensive yet fascinating little input device – the thumb joystick. Many people would recognise this as similar to the joystick in various types of gaming consoles, and they would be right. Let’s have a look:
In the image above the joystick has been soldered into the matching breakout board. Unless you are making your own PCBs, you will want the breakout board:
The joystick consists of two 10k variable resistors, spring-loaded with centre return; also a SPST button that is activated by pushing down on the joystick:
In order to use this joystick, we need an idea of the values that it can return. I have done this in three ways:
First of all, I connected a multimeter and measured the resistance of each axis. For the vertical axis, dead centre was 3.77k ohms, maximum up was 4.7k, with a maximum of 5.9k between centre and maximum – very odd. The vertical minimum was 83 ohms. For the horizontal, dead centre was around 3.73k ohms, full left was 4.78k, via 5.38k; full right was 180 ohms without any odd high values in between. However, those values didn’t feel right.
Secondly, I have recorded a visual representation of the horizontal and vertical axes’ effect on the supply voltage, using my little oscilloscope. With regards to the following two video clips, the supply voltage is 5V; the ‘scope display is set to 1V/division, with 0V at the bottom of the screen.
The horizontal axis:
and the vertical axis:
Finally, I connected the horizontal and vertical output to analog inputs on my Arduino, and used analogRead() to see how the joystick returned analogRead() values. The following video clip demonstrates this using an LCD to display the values. Furthermore, here is the sketch used for the following demonstration: demo sketch.pdf
It would seem that there is a lot of ‘dead area’… postions where there is no change in reading, where one would assume there to be a change. Again, this can be programmed out in your sketch by a little calibration and measurement.
Now we know what values it returns, we can start to understand how to control things. When it comes to use the joystick in your own projects, it would pay to recreate a measurement circuit and note down the values your joystick returns; in order to be able to calibrate your software to use the joystick appropriately you may need to compensate for the hardware irregularities of the joystick.
Overall however, it is an interesting and easy product to integrate into your projects. This post today is just an introduction, later on the joysticks will be used in other projects and so on. High resolution photos are available on flickr. And if you enjoy my tutorials, or want to introduce someone else to the interesting world of Arduino – check out my new book “Arduino Workshop” from No Starch Press.
In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitter, Google+, subscribe for email updates or RSS using the links on the right-hand column? And join our friendly Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other – and we can all learn something.
Latest posts by John Boxall (see all)
- Arduino Workshop – A Hands-On Introduction with 65 Projects - May 6, 2014
- Project Review – Silicon Chip Capacitance Substitution Box - April 23, 2014
- Add long-distance connectivity to your Arduino with the CATkit System - April 13, 2014