mirror of
https://github.com/modelec/PAMI-2025.git
synced 2026-03-18 21:40:36 +01:00
add switch read
This commit is contained in:
@@ -47,6 +47,8 @@ struct Step {
|
|||||||
// Servo Moteur
|
// Servo Moteur
|
||||||
#define SERVO_PIN 15
|
#define SERVO_PIN 15
|
||||||
#define EMG_PIN 5
|
#define EMG_PIN 5
|
||||||
|
// Bouton de sélection de côté
|
||||||
|
#define SWITCH_PIN 14
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -9,4 +9,6 @@ int getStepsForDistance(float cm);
|
|||||||
|
|
||||||
int getRotationSteps(float angleDeg);
|
int getRotationSteps(float angleDeg);
|
||||||
|
|
||||||
|
int readSwitchOnce(int pin);
|
||||||
|
|
||||||
#endif // PAMI_UTILS_H
|
#endif // PAMI_UTILS_H
|
||||||
|
|||||||
@@ -225,6 +225,8 @@ void loop() {
|
|||||||
Serial.println("Trigger initialized");
|
Serial.println("Trigger initialized");
|
||||||
} else if (digitalRead(TIRETTE_PIN) == HIGH && tirettePose) {
|
} else if (digitalRead(TIRETTE_PIN) == HIGH && tirettePose) {
|
||||||
Serial.println("Trigger removed");
|
Serial.println("Trigger removed");
|
||||||
|
Serial.print("Switch : ");
|
||||||
|
Serial.println(readSwitchOnce(SWITCH_PIN) ? "OFF" : "ON");
|
||||||
delay(START_DELAY);
|
delay(START_DELAY);
|
||||||
Serial.println("Starting the script");
|
Serial.println("Starting the script");
|
||||||
startTime = millis();
|
startTime = millis();
|
||||||
|
|||||||
@@ -29,3 +29,11 @@ int getRotationSteps(float angleDeg) {
|
|||||||
|
|
||||||
return (int) round(microStepsForAngle);
|
return (int) round(microStepsForAngle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int readSwitchOnce(int pin) {
|
||||||
|
pinMode(SWITCH_PIN, INPUT_PULLUP);
|
||||||
|
delay(10);
|
||||||
|
const bool switchState = digitalRead(SWITCH_PIN);
|
||||||
|
pinMode(SWITCH_PIN, INPUT); // retire le pull-up
|
||||||
|
return switchState;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user