Benutzer-Werkzeuge

Webseiten-Werkzeuge


hello_mbot_kalibrierung

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen RevisionVorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
hello_mbot_kalibrierung [2025/02/19 16:31] – [Quellcode (engl. Sourcecode)] torsten.roehlhello_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 = 20// wird überschrieben! +unsigned long time90degree; 
-// turn90Degree+ 
 +// turn90Degree...
 bool t90d_isTurning = false; bool t90d_isTurning = false;
 unsigned long t90d_turnStartTime = 0; unsigned long t90d_turnStartTime = 0;
-//actionCalibration...+// actionCalibration...
 unsigned long ac_turnStartTimeLeft  = 0; unsigned long ac_turnStartTimeLeft  = 0;
 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; +bool ac_isTurning = false; 
-static bool ac_isLeftTurning = false; +bool ac_isLeftTurning = false; 
-static bool ac_isRightTurning = false; +bool ac_isRightTurning = false; 
-static bool ac_calibrationDone = false;+bool ac_calibrationDone = false;
 //actionTest... //actionTest...
-static bool at_doneLeft = false; +bool at_doneLeft = false; 
-static bool at_doneRight = false; +bool at_doneRight = false; 
-static bool at_testComplete = false;+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     = true;     t90d_isTurning     = true;
-    int dir           = 1+    int dir = left ? -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;
  
-  if (t90d_isTurning && millis() - t90d_turnStartTime >= time90degree) { +  // step: ... finished 
-    motor1.stop(); +  motor1.stop(); 
-    motor2.stop(); +  motor2.stop(); 
-    t90d_isTurning = false; +  t90d_isTurning = false;
-    return true; +
-  }+
  
-  return false;+  return true;
 } }
  
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 in den **Ruhezustand** zurück.  
    * 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