Prints pedal position percentages over Serial.
const int Pin_Gas = A2;
const int Pin_Brake = A1;
const int Pin_Clutch = A0;
void setup() {
Serial.begin(115200);
while (!Serial);
Serial.println("Starting...");
}
void loop() {
if (Serial.read() != -1) {
delay(2000);
}
Serial.print("Pedals:");
Serial.print("\tGas: [ ");
Serial.print(gasPedal);
Serial.print("% ]");
}
if (pedals.
hasPedal(SimRacing::Brake)) {
Serial.print("\tBrake: [ ");
Serial.print(brakePedal);
Serial.print("% ]");
}
if (pedals.
hasPedal(SimRacing::Clutch)) {
int clutchPedal = pedals.
getPosition(SimRacing::Clutch);
Serial.print("\tClutch: [ ");
Serial.print(clutchPedal);
Serial.print("% ]");
}
Serial.println();
delay(100);
}
Header file for the Sim Racing Library.
Interface with the Logitech pedals (Gas, Brake, and Clutch)
void serialCalibration(Stream &iface=Serial)
Runs an interactive calibration tool using the serial interface.
bool hasPedal(PedalID pedal) const
Checks if a given pedal is present in the class.
virtual bool update()
Perform a poll of the hardware to refresh the class state.
virtual void begin()
Initialize the hardware (if necessary)
long getPosition(PedalID pedal, long rMin=0, long rMax=100) const
Retrieves the buffered position for the pedal, rescaled to a nominal range using the calibration valu...