Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int demarrage = 0; // variable d'état (demmarage)
- int recharge = 0; // état de recharge(batterie)
- int position1 = 0; // position du robot
- int client = 5; // position du client
- // ----------------------------
- int ingredients[10] = {1, 0, 0, 0, 0, 1, 0, 0, 0, 0};
- void setup() {
- // Configuration:
- pinMode(5, OUTPUT); // marche avant
- pinMode(6, OUTPUT); // marche arriere
- pinMode(8, INPUT_PULLUP); // capteur
- }
- void loop() {
- // Boucle principal:
- //demmarage
- while (digitalRead(8) == 1 || recharge == 1) {
- demarrage = 0;
- position1 = 0;
- }
- demarrage = 1;
- delay(500);
- while (position1 < 10){
- while (digitalRead(8) == 1){ //detection distributeurs
- digitalWrite(5,HIGH);
- }
- position1 = position1 + 1; //incrémentation position du robot
- delay(1000);
- if (ingredients[position1 - 1] == 1){ //verfication ingrédients
- digitalWrite(5,LOW); //arret pou recuperer ingrédients
- delay(5000);
- }
- }
- digitalWrite(5,LOW); //fin de parcours avant
- delay(500);
- while (position1 > client){ //recherche du client
- while(digitalRead(8) == 1){ //detection place
- digitalWrite(6,HIGH);
- }
- position1 = position1 - 1; //décrementation position du robot
- delay(500);
- }
- digitalWrite(6,LOW);
- delay(5000);
- while (position1 > 0){ // retour à la borne
- while(digitalRead(8) == 1){ //détection placement
- digitalWrite(6,HIGH);
- }
- position1 = position1 - 1; // mise à jour position du robot
- delay(500);
- }
- digitalWrite(6,LOW); //arret final
- position1 = 0; //mise à jour position
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement