Skip to content

Commit d330f29

Browse files
authored
Support Pedals as Built-in Devices (#480)
* Added paddle support. * Initial Pedal Code (Need to adust numbers) * Adjusted values * #206 fixed variables to more percise values
1 parent 0750ce3 commit d330f29

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

arduino/leads_vec_power/Pedal.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const int hallSensorPin = A0; // Analog pin connected to Hall sensor
2+
float restValue = 0.157380254154448; // Variable for rest value
3+
float maxValue = 0.697947214076246; // Variable for max value
4+
5+
// Function to map ADC value to a range between 0 and 1
6+
float mapToRange(int adcValue, int adcMaxValue) {
7+
return (float)adcValue / adcMaxValue;
8+
}
9+
void setup() {
10+
Serial.begin(9600); // Initialize serial communication at 9600 bps
11+
}
12+
void loop() {
13+
// Read the ADC value from the Hall sensor
14+
int adcValue = analogRead(hallSensorPin);
15+
// Map the ADC value to a range between 0 and 1
16+
float pedalValue = (mapToRange(adcValue, 1023) - restValue) / maxValue;
17+
// Print the pedal value to the Serial Monitor
18+
Serial.print("Pedal Value: ");
19+
Serial.println(pedalValue, 2); // Print with 2 decimal places
20+
21+
delay(500); // Delay for half a second
22+
}

arduino/leads_vec_power/leads_vec_power.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "LEADS.h"
2+
#include "Pedal.h"
23

34
const int PIN_VOT[] = {A0};
45

0 commit comments

Comments
 (0)