Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. #include "robot-config.h"
  2.  
  3.  
  4. int main() {
  5.  
  6.  
  7. while(true){
  8. {
  9.  
  10. while(Bumper.pressing())
  11. {
  12. RightMotor.stop(brakeType::brake);
  13. LeftMotor.stop(brakeType::brake);
  14. task::sleep(1000);
  15.  
  16.  
  17. if (Sonar.distance(distanceUnits::cm) < 20 )
  18. {
  19. RightMotor.startRotateFor(-.5,rotationUnits::rev,20,velocityUnits::pct);
  20. LeftMotor.rotateFor(.5,rotationUnits::rev,20,velocityUnits::pct);
  21. RightMotor.startRotateFor(-1,rotationUnits::rev,20,velocityUnits::pct);
  22. LeftMotor.rotateFor(1,rotationUnits::rev,20,velocityUnits::pct);
  23.  
  24. }
  25. else
  26. {
  27. RightMotor.startRotateFor(.5,rotationUnits::rev,20,velocityUnits::pct);
  28. LeftMotor.rotateFor(-.5,rotationUnits::rev,20,velocityUnits::pct);
  29. RightMotor.startRotateFor(-1,rotationUnits::rev,20,velocityUnits::pct);
  30. LeftMotor.rotateFor(1,rotationUnits::rev,20,velocityUnits::pct);
  31.  
  32. RightMotor.stop(brakeType::brake);
  33. LeftMotor.stop(brakeType::brake);
  34. RightMotor.spin(directionType::fwd);
  35. LeftMotor.spin(directionType::fwd);
  36. }
  37. }
  38. RightMotor.startRotateFor(1,rotationUnits::rev,50,velocityUnits::pct);
  39. LeftMotor.startRotateFor(1,rotationUnits::rev,50,velocityUnits::pct);
  40. }
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement