Skip to content

Instantly share code, notes, and snippets.

@robertcedwards
Last active March 10, 2019 05:44
Show Gist options
  • Save robertcedwards/18df09bae7e5210a7fe7a262afbf1c57 to your computer and use it in GitHub Desktop.
Save robertcedwards/18df09bae7e5210a7fe7a262afbf1c57 to your computer and use it in GitHub Desktop.
Handbrake control with mapping for range
void setup() {
pinMode(0, INPUT_PULLUP);
}
void loop() {
int val = analogRead(0); //read pot value
val = map(val, 625, 220, 0, 1024);//map range to normal pot range
val = constrain(val, 0, 1024);//then constrain for noise reduction
Joystick.X(val);
//Serial.println(val)
delay(50);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment