Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Wire.h>
- #include <Adafruit_ADS1X15.h>
- #include <Joystick.h>
- Adafruit_ADS1115 ads1115;
- Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID);
- int Brake = 0;
- void setup()
- /*
- GAIN_TWOTHIRDS (for an input range of +/- 6.144V)
- GAIN_ONE (for an input range of +/-4.096V)
- GAIN_TWO (for an input range of +/-2.048V)
- GAIN_FOUR (for an input range of +/-1.024V)
- GAIN_EIGHT (for an input range of +/-0.512V)
- GAIN_SIXTEEN (for an input range of +/-0.256V)
- */
- {
- ads1115.setGain(GAIN_TWOTHIRDS);
- ads1115.begin();
- Joystick.begin();
- }
- void loop()
- {
- int32_t adc0;
- adc0 = ads1115.readADC_SingleEnded(0);
- Joystick.setXAxisRange(0, 32767);
- Joystick.setXAxis(Brake);
- Brake = adc0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement