hello_mbot_kalibrierung
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende Überarbeitung | ||
hello_mbot_kalibrierung [2025/02/19 16:31] – [Quellcode (engl. Sourcecode)] torsten.roehl | hello_mbot_kalibrierung [2025/02/19 19:55] (aktuell) – [Bedienung] torsten.roehl | ||
---|---|---|---|
Zeile 112: | Zeile 112: | ||
// Allgemein | // Allgemein | ||
int speed = 100; // Motor speed | int speed = 100; // Motor speed | ||
- | unsigned long time90degree | + | unsigned long time90degree; |
- | // turn90Degree | + | |
+ | // turn90Degree... | ||
bool t90d_isTurning = false; | bool t90d_isTurning = false; | ||
unsigned long t90d_turnStartTime = 0; | unsigned long t90d_turnStartTime = 0; | ||
- | // | + | // actionCalibration... |
unsigned long ac_turnStartTimeLeft | unsigned long ac_turnStartTimeLeft | ||
unsigned long ac_turnTimeLeft = 0; | unsigned long ac_turnTimeLeft = 0; | ||
unsigned long ac_turnStartTimeRight = 0; | unsigned long ac_turnStartTimeRight = 0; | ||
unsigned long ac_turnTimeRight = 0; | unsigned long ac_turnTimeRight = 0; | ||
- | static | + | bool ac_isTurning = false; |
- | static | + | bool ac_isLeftTurning = false; |
- | static | + | bool ac_isRightTurning = false; |
- | static | + | bool ac_calibrationDone = false; |
// | // | ||
- | static | + | bool at_doneLeft = false; |
- | static | + | bool at_doneRight = false; |
- | static | + | bool at_testComplete = false; |
enum State { | enum State { | ||
Zeile 168: | Zeile 169: | ||
bool turn90Degree(bool left) { | bool turn90Degree(bool left) { | ||
+ | // step: ...start turning | ||
if (!t90d_isTurning) { | if (!t90d_isTurning) { | ||
motor1.stop(); | motor1.stop(); | ||
motor2.stop(); | motor2.stop(); | ||
t90d_isTurning | t90d_isTurning | ||
- | int dir | + | int dir = left ? 1 : -1; |
- | if (!left) | + | |
- | dir = -1; | + | |
motor1.run(dir * speed); | motor1.run(dir * speed); | ||
motor2.run(dir * speed); | motor2.run(dir * speed); | ||
t90d_turnStartTime = millis(); | t90d_turnStartTime = millis(); | ||
+ | return false; | ||
} | } | ||
+ | // step: ...in progress | ||
+ | if (millis() - t90d_turnStartTime < time90degree) | ||
+ | return false; | ||
- | | + | |
- | motor1.stop(); | + | motor1.stop(); |
- | motor2.stop(); | + | motor2.stop(); |
- | t90d_isTurning = false; | + | t90d_isTurning = false; |
- | return true; | + | |
- | } | + | |
- | return | + | return |
} | } | ||
Zeile 342: | Zeile 345: | ||
⚡ **Schritt 3: | ⚡ **Schritt 3: | ||
- | ▶ **Nach dem Testlauf** kehrt der mBot in den **Ruhezustand** zurück. | + | ▶ **Nach dem Testlauf** kehrt der mBot durch Drückens des Tasters |
* Der Vorgang kann **von vorne** gestartet werden. | * Der Vorgang kann **von vorne** gestartet werden. | ||
hello_mbot_kalibrierung.1739982668.txt.gz · Zuletzt geändert: 2025/02/19 16:31 von torsten.roehl