Advertisement
Guest User

Untitled

a guest
Mar 30th, 2020
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. int demarrage = 0; // variable d'état (demmarage)
  2. int recharge = 0; // état de recharge(batterie)
  3. int position1 = 0; // position du robot
  4. int client = 5; // position du client
  5. // ----------------------------
  6. int ingredients[10] = {1, 0, 0, 0, 0, 1, 0, 0, 0, 0};
  7.  
  8. void setup() {
  9. // Configuration:
  10. pinMode(5, OUTPUT); // marche avant
  11. pinMode(6, OUTPUT); // marche arriere
  12. pinMode(8, INPUT_PULLUP); // capteur
  13.  
  14. }
  15.  
  16. void loop() {
  17. // Boucle principal:
  18. //demmarage
  19. while (digitalRead(8) == 1 || recharge == 1) {
  20. demarrage = 0;
  21. position1 = 0;
  22. }
  23. demarrage = 1;
  24. delay(500);
  25.  
  26. while (position1 < 10){
  27. while (digitalRead(8) == 1){ //detection distributeurs
  28. digitalWrite(5,HIGH);
  29. }
  30. position1 = position1 + 1; //incrémentation position du robot
  31. delay(1000);
  32. if (ingredients[position1 - 1] == 1){ //verfication ingrédients
  33. digitalWrite(5,LOW); //arret pou recuperer ingrédients
  34. delay(5000);
  35. }
  36. }
  37. digitalWrite(5,LOW); //fin de parcours avant
  38. delay(500);
  39.  
  40. while (position1 > client){ //recherche du client
  41. while(digitalRead(8) == 1){ //detection place
  42. digitalWrite(6,HIGH);
  43. }
  44. position1 = position1 - 1; //décrementation position du robot
  45. delay(500);
  46. }
  47. digitalWrite(6,LOW);
  48. delay(5000);
  49.  
  50. while (position1 > 0){ // retour à la borne
  51. while(digitalRead(8) == 1){ //détection placement
  52. digitalWrite(6,HIGH);
  53. }
  54. position1 = position1 - 1; // mise à jour position du robot
  55. delay(500);
  56. }
  57. digitalWrite(6,LOW); //arret final
  58. position1 = 0; //mise à jour position
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement