Guest User

Untitled

a guest
Nov 14th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. #include <IRremote.h>
  2.  
  3. Rspeedd = getDistance(degreesRight, 'R'); // detection distance on right side
  4. delay(delay_time); // waiting for servo motor to be stable
  5.  
  6. // if left distance greater than right
  7. if (Lspeedd > Rspeedd) {
  8. directionn = Lgo; // go left
  9. }
  10.  
  11. if (Lspeedd <= Rspeedd) {//if left distance less than right
  12. directionn = Rgo; //go right
  13. }
  14.  
  15. if (Lspeedd < 15 && Rspeedd < 15) { //if distance less 10mm both right and left
  16. directionn = Bgo; //go back
  17. }
  18.  
  19. if (SM == HIGH) {//middle sensor in black area
  20. if (SL == LOW & SR == HIGH) {//left sensor in black area, right sensor in white, turn left
  21. left(0);
  22. }
  23. else if (SR == LOW & SL == HIGH) {//left white, right black, run right
  24. right(0);
  25. }
  26. else { // left and right both in white, go straight
  27. advance(0);
  28. }
  29. }
  30. // middle sensor in white area
  31. else {
  32. if (SL == LOW & SR == HIGH) { // left black ,right white, turn left
  33. left(0);
  34. }
  35. else if (SR == LOW & SL == HIGH) {
  36. right(0);
  37. }
  38. else { //left and right both in white, stop
  39. stopp(0);
  40. }
  41. }
  42. stopPressed = stopCommandPressed();
  43. if (stopPressed) {
  44. break;
  45. }
Add Comment
Please, Sign In to add comment