Advertisement
LandoRo

Simple break pedal

Aug 31st, 2024
413
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. #include <Wire.h>
  2.  
  3. #include <Adafruit_ADS1X15.h>
  4. #include <Joystick.h>
  5. Adafruit_ADS1115 ads1115;
  6. Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID);
  7. int Brake = 0;
  8.  
  9. void setup()
  10. /*
  11.    GAIN_TWOTHIRDS (for an input range of +/- 6.144V)
  12.    GAIN_ONE (for an input range of +/-4.096V)
  13.    GAIN_TWO (for an input range of +/-2.048V)
  14.    GAIN_FOUR (for an input range of +/-1.024V)
  15.    GAIN_EIGHT (for an input range of +/-0.512V)
  16.    GAIN_SIXTEEN (for an input range of +/-0.256V)
  17. */
  18.  
  19. {
  20.   ads1115.setGain(GAIN_TWOTHIRDS);
  21.   ads1115.begin();
  22.   Joystick.begin();
  23. }
  24.  
  25. void loop()
  26. {
  27.   int32_t adc0;
  28.   adc0 = ads1115.readADC_SingleEnded(0);
  29.   Joystick.setXAxisRange(0, 32767);
  30.   Joystick.setXAxis(Brake);
  31.   Brake = adc0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement