Introduction: Single Axis Joystick Controller With Arduino

About: Hi, I'm Austin Allen, the founder and owner at Elation Sports Technologies. Based out of Los Angeles CA, I specialize in innovate product designs and projects related to sports, cinematography, sensing and con…

In this project, I demonstrate three different use cases for single-axis joysticks with an Arduino Nano microcontroller. The joysticks used in this project can be found here!

Single-axis joysticks have historically been out of reach for hobbyists due to their large size and high cost, and while dual-axis joysticks are ubiquitous and commonly available, sometimes a user just wants to control a single axis. For example:

  • Controlling the light output level from an LED
  • Setting the angle of a rudder, airfoil, or RC car's steering angle for hobbyist projects using a low-cost SG90 servo motor
  • Jogging the position of a stepper motor on a DIY CNC machine

In this article, I share a demo unit that utilizes 3 x single-axis joystick module breakout boards to demonstrate these three applications!

Disclosure: Some of the links in this article are affiliate links. This means that, at zero cost to you, I will earn an affiliate commission if you click through the link and finalize a purchase.

Supplies

Step 1: Electrical Hardware

Solder the 22 AWG hookup wire to provide power (VCC, 5V) and GND to each of the three single-axis joysticks in parallel. Run one wire to each of the signal pads on each single-axis joystick board, and solder all 5 x wires to the aviation connector mounted on the side wall of the demo enclosure.

Build the breadboard circuit for the Arduino Nano clone board as shown in the image. The pin connections leading to the Arduino are as follows:

  • D2: LED Red
  • D3: LED Green
  • D4: LED Blue
  • D5: Servo PWM Signal
  • D7: TMC2208 STEP
  • D8: TMC2208 DIR
  • A0: Joystick 1 Signal
  • A1: Joystick 2 Signal
  • A2: Joystick 3 Signal

The Arduino Nano receives its 5V power from its USB port, which you can connect to a 5VDC external power supply, or to a typical PC/laptop USB port. The stepper motor is run off an external 12VDC power supply, and controlled using the TMC2208 stepper motor driver. Take care not to connect 12V positive power to any of the Arduino pins, or you risk damaging the Arduino!

Step 2: Mechanical Hardware

The demo unit was created by laser-cutting sheets of 1/8" thick black acrylic. The DXF file used to create the laser cutting files was made using Autodesk Fusion 360. The side wall of the demo enclosure was 3D printed using black PLA filament, and then M3 threaded inserted were installed around the top and bottom rims using a standard soldering iron. Some screw caps were also printed using black PLA filament for the demo unit to rest on. The top 3 x joystick caps were designed in Autodesk Fusion 360 and printed using the same PLA filament, and they were designed to be press-fit onto the joystick handles. The three styles of joystick I demonstrate here are:

  • Paddle type, for controlling the color and brightness of the RGB LED
  • Cup/trigger type, for controlling the position of the servo motor, e.g. for hobbyist RC boats, planes, and vehicles
  • Thumbstick type, used for jogging the position of a stepper, brushed DC, or BLDC motor

The top and bottom laser-cut acrylic sheets are fastened to the 3D-printed enclosure wall using M3 screws, and M2 standoffs + screws and nuts secure the 3 x joysticks to the underside of the top face of the demo unit. A 5-pin aviation connector is mounted to the side of the demo's printed enclosure wall.

Step 3: Programming

The code used to create this project can be found on my Github page:

  1. Single_Axis_Joystick_Demo_Box.ino
  2. Simple demo code for demonstrating use of single-axis joysticks with:
  3. An RGB LED
  4. A hobbyist servo motor (SG90)
  5. A NEMA17 stepper motor

The code is loaded onto the Arduino Nano using the Arduino IDE, which is free software often used for hobbyist projects!

The general working principle of the code is as follows:

  1. Initial readings are taken for the 3 x joysticks.
  2. The joystick readings are continuously read in the loop() function, and rolling averages are taken to smooth them out to reduce jitter/signal noise.
  3. The Arduino map() function is used to convert the joystick readings into values that are then used for:
  4. LED brightness and color (red when the joystick is pushed forward, and green when it is pulled back
  5. Servo angular position
  6. Stepper motor jog speed and direction
  7. The LED brightness is set using the SoftPWM library. PWM stands for pulse-width modulated, which is useful for setting the effective brightness of an LED. By pulsing it for more On time than Off time, the LED will appear brighter, and this is how it appears to the eye when it is powered on and off quickly.
  8. The servo position is controlled using an Arduino Servo object definition which, similar to SoftPWM, sends a PWM signal to the servo motor, whose on-board circuitry controls its position.
  9. The stepper motor jogging speed and direction is set using the AccelStepper library, which is useful for defining accelerations and velocities for controlling stepper motors.

Step 4: Demonstration

The linked video introduces the single-axis joystick breakout modules, and shares the demo unit showcasing their versatility in the following three uses cases!

  • Controlling the light output level from an LED
  • Setting the angle of a rudder, airfoil, or RC car's steering angle for hobbyist projects using a low-cost SG90 servo motor
  • Jogging the position of a stepper motor on a DIY CNC machine

Step 5: Conclusion

In this article, I demonstrated how to use a single-axis joystick breakout module, which is perfect for hobbyists looking for a lost-cost, small form factor joystick for user input along a single axis! The demo unit above demonstrates the versatility of these single-axis joystick modules for many different types of projects. The modules can be purchased from Elation Sports Technologies here!

In the demo unit, multiple concepts were covered, utilizing an Arduino Nano development board :

  1. Taking analog readings from 3 x single-axis joystick modules.
  2. Controlling the color and brightness of an RGB LED using the SoftPWM library.
  3. Controlling the position of a hobbyist servo motor (SG90).
  4. Setting the jog speed/velocity of a NEMA17 stepper motor using the AccelStepper library.


Check out our other Instructables articles:


Our website's blog posts offer more inspiration for your next project! We have a free newsletter with project ideas if you'd like to sign up!


My business offers mechanical and electrical engineering design consulting. I'd be happy to discuss your project's needs to see how we may assist you - simply reach out to schedule a chat.


Thanks for reading!


Austin Allen

Founder and Owner

Elation Sports Technologies LLC