Skip to content

Commit

Permalink
Adapt to joystick library
Browse files Browse the repository at this point in the history
* Use new constructor with custom range

* Cosmetic changes
  • Loading branch information
edumardo authored Sep 13, 2019
1 parent 5fe596c commit b53ba01
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions examples/differentialSteringSingleJoystick.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,27 @@ const int serialDelay = 200;
int pinJoystickX = A0;
int pinJoystickY = A1;
int pinJoystickButton = 5;
int noActionLimit = 100;
Joystick joystick(pinJoystickX, pinJoystickY, pinJoystickButton, noActionLimit);
int noActionLimit = 0;
int minRange = -127;
int maxRange = 127;
Joystick joystick(pinJoystickX, pinJoystickY, pinJoystickButton, noActionLimit, minRange, maxRange);

void setup()
{
Serial.begin(9600);
joystick.invertYAxis(); // Y-axis decreases when I push forward in my hardware
}

void loop()
{
// INPUTS (-127..+127)
int XValue = map(joystick.getXValue(), 0, 1023, -127, 127);
int YValue = map(joystick.getYValue(), 0, 1023, 127, -127); // (127..-127): YValue decreases when push forward the Y axis.
int XValue = joystick.getXValue();
int YValue = joystick.getYValue();
bool buttonValue = joystick.getbuttonValue();

// OUTPUTS
int nMotMixL; // Motor (left) mixed output (-128..+127)
int nMotMixR; // Motor (right) mixed output (-128..+127)
int nMotMixL; // Motor (left) mixed output (-127..+127)
int nMotMixR; // Motor (right) mixed output (-127..+127)

// CONFIG
// - fPivYLimt : The threshold at which the pivot action starts
Expand Down

0 comments on commit b53ba01

Please sign in to comment.