Go Down

Topic: Erreur (Read 539 times) previous topic - next topic

Harduino

Aug 14, 2013, 01:50 am Last Edit: Sep 08, 2013, 07:42 pm by Harduino Reason: 1
.

fdufnews

Il suffit d'attendre que la coupure cesse avznt de continuer

Code: [Select]
void loop() {
if (digitalRead(OPTO) == NOT_CUT) digitalWrite(ledPin, LOW); else digitalWrite(ledPin, HIGH);
if (digitalRead(OPTO) == CUT) {    // Opto test
   count = count + 1;                      // Increment the count variable
   if (count == 3) count = 0;            // Resetting the variable count 2=>0
   if (count == 0){
      // motor stopped
      digitalWrite(EN1, LOW);
      digitalWrite(EN2, LOW);
   }
   if (count == 1){
     // Motor forward
     digitalWrite(EN1, HIGH);
     digitalWrite(EN2, HIGH);
     myStepper.step(stepsPerRevolution);
   }
   if (count == 2){
    // Motor backward
    digitalWrite(EN1, HIGH);
    digitalWrite(EN2, HIGH);
    myStepper.step(-stepsPerRevolution);
  }
  while(digitalRead(OPTO) == CUT);  // On attends que la coupure disparaisse
}
}

Go Up