Stap 4: #program en code
Hier wordt code weergegevenKopieer en plak het
int sensor1 = 0;
int sensor2 = 1;
int motor1 = 3;
int motor2 = 4;
VOID Setup {}
pinMode(sensor1,INPUT);
pinMode(sensor2,INPUT);
pinMode(motor1,OUTPUT);
pinMode(motor2,OUTPUT);
}
void loop {}
C:
if(sensor1==low) {}
digitalWrite(motor1,HIGH);
digitalWrite(motor2,LOW);
delay(500);
digitalWrite(motor1,HIGH);
digitalWrite(motor2,HIGH);
A:
if(sensor2==low) {}
digitalWrite(motor1,LOW);
digitalWrite(motor2,HIGH);
delay(500);
digitalWrite(motor1,HIGH);
digitalWrite(motor2,HIGH);
delay(1000);
goto C;
} goto A;
if(sensor2==low) {}
digitalWrite(motor1,HIGH);
digitalWrite(motor2,LOW);
delay(500);
digitalWrite(motor1,HIGH);
digitalWrite(motor2,HIGH);
B:
if(sensor1==low) {}
digitalWrite(motor1,LOW);
digitalWrite(motor2,HIGH);
delay(500);
digitalWrite(motor1,HIGH);
digitalWrite(motor2,HIGH);
delay(1000);
goto C;
}
goto B;
}
}
}
Hier wordt de 500ms vertraging gebruikt omdat poort is gesloten in deze tijd. u kunt dit wijzigen volgens concreet antwoord