File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 11#include " LEADS.h"
2+ #include " Pedal.h"
23
34const int PIN_VOT [] = {A0 };
45
You can’t perform that action at this time.
0 commit comments