Skip to content

A TomStick library is an Arduino library for simply controlling the axes of the joystick.

License

Notifications You must be signed in to change notification settings

Dhanabhon/TomStick

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TomStick

PlatformIO Registry License

A TomStick library is an Arduino library for simply controlling the axes of the joystick.

Take control of your joystick with ease using the TomStick library - the ultimate solution for precise and simple axis control on Arduino.

Example

#include <TomStick.h>

#define JOYSTICK_X_PIN          A0
#define JOYSTICK_Y_PIN          A1

TomStick joystick(JOYSTICK_X_PIN, JOYSTICK_Y_PIN);
TomStick::Direction currentJoystickState = TomStick::UNKNOWN;

void setup() {
    Serial.begin(115200);
    
    // Initialize the joystick values
    joystick.begin();
    // Calibreate the joystick center position
    joystick.calibrate();
    // Set the dead zone of the joystick (default 50)
    joystick.setDeadZoneThreshold(55);
}

void loop() {
    currentJoystickState = joystick.onMove();

    switch (currentJoystickState)
    {
    case TomStick::CENTER:
      Serial.println("CENTER");
      break;
    case TomStick::UP_LEFT:
      Serial.println("UP-LEFT");
      break;
    case TomStick::UP:
      Serial.println("UP");
      break;
    case TomStick::UP_RIGHT:
      Serial.println("UP-RIGHT");
      break;
    case TomStick::LEFT:
      Serial.println("LEFT");
      break;
    case TomStick::RIGHT:
      Serial.println("RIGHT");
      break;
    case TomStick::DOWN_LEFT:
      Serial.println("DONW-LEFT");
      break;
    case TomStick::DOWN:
      Serial.println("DOWN");
      break;
    case TomStick::DOWN_RIGHT:
      Serial.println("DOWN-RIGHT");
      break;
    default:
      Serial.println("UNKNOWN");
      break;
    }
}

About

A TomStick library is an Arduino library for simply controlling the axes of the joystick.

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages