Arduino Sim Racing Library v1.1.5
Loading...
Searching...
No Matches
HandbrakePrint.ino
1/*
2 * Project Sim Racing Library for Arduino
3 * @author David Madison
4 * @link github.com/dmadison/Sim-Racing-Arduino
5 * @license LGPLv3 - Copyright (c) 2022 David Madison
6 *
7 * This file is part of the Sim Racing Library for Arduino.
8 *
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 */
22
28#include <SimRacing.h>
29
30const int Pin_Handbrake = A2;
31
32SimRacing::Handbrake handbrake(Pin_Handbrake);
33
34
35void setup() {
36 handbrake.begin(); // initialize handbrake pins
37
38 // if you have one, your calibration line should go here
39
40 Serial.begin(115200);
41 while (!Serial); // wait for connection to open
42
43 Serial.println("Starting...");
44}
45
46void loop() {
47 // send some serial data to run conversational calibration
48 if (Serial.read() != -1) {
49 handbrake.serialCalibration();
50 delay(2000);
51 }
52
53 handbrake.update();
54
55 Serial.print("Handbrake: ");
56
57 int pos = handbrake.getPosition();
58 Serial.print(pos);
59 Serial.print("%");
60 Serial.println();
61
62 delay(100);
63}
Header file for the Sim Racing Library.
Interface with analog handbrakes that use hall effect sensors.
Definition SimRacing.h:688
virtual void begin()
Initializes the pin for reading from the handbrake.
long getPosition(long rMin=0, long rMax=100) const
Retrieves the buffered position for the handbrake axis, rescaled to a nominal range using the calibra...
virtual bool update()
Polls the handbrake to update its position.
void serialCalibration(Stream &iface=Serial)
Runs an interactive calibration tool using the serial interface.