Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

JoystickLib :: Joystick library for Arduino

Build Status


Licensed under GPL v2 (the "License"); you may not use this library except in compliance with the License. You may obtain a copy of the License at:

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.


This is a library that provides an API foor reading one or more Joysticks attached to an Arduino. This is a multi-instance library, so you can read multiple joysticks. Only one analog pin is needed per axis. Most analog joysticks are basically just (2) potentiometers that act as voltage dividers. This library is based on the JoystickShield library ( This library, however, does not process button events. It also does not process joystick events separately. Events are fired immediately upon detecting a state change (if, and only if, a state change actually occurs).

How to use

Copy the entire folder containing this library to the "libraries" folder of your Arduino installation or sketchbook. Then include JoystickLib.h in your sketch. See example below:

#include "Arduino.h"
#include "JoystickLib.h"

// Create joystick instance attached to pins A0 (X-axis) and A1
// Y-axis. This will also set the default threshold values.
Joystick stick(A0, A1);

void setup() {

void loop() {

	Serial.print("X = ");

	Serial.print("Y = ");


How to install

If you are using PlatformIO (, you can simply run the following command:

platformio lib install joysticklib

Otherwise, download the zip from then extract its contents to a folder called "ArduinoHAF" and then move that folder to your libraries folder.

You can’t perform that action at this time.