Advertisement
andreahmed

Untitled

May 6th, 2017
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. if(leftMotorSpeed > 0 && rightMotorSpeed > 0 )
  2. {
  3. // set motor speeds using the two motor speed variables above
  4. set_motors_position(leftMotorSpeed, rightMotorSpeed);
  5. }
  6. else
  7. {
  8. set_motors_negative(leftMotorSpeed, rightMotorSpeed);
  9.  
  10. }
  11.  
  12. }
  13.  
  14. void set_motors_negative(int motor1speed, int motor2speed)
  15. {
  16. if (motor1speed > M1_maksimum_speed ) motor1speed = M1_maksimum_speed;
  17. if (motor2speed > M2_maksimum_speed ) motor2speed = M2_maksimum_speed;
  18. if (motor1speed < 0)
  19. {
  20. motor1speed *=-1
  21.  
  22. motor1.setSpeed(motor1speed);
  23. motor1.run(BACKWARD);
  24.  
  25. }
  26. else{
  27.  
  28. motor2speed *=-1
  29.  
  30. motor2.setSpeed(motor2speed);
  31. motor2.run(BACKWARD);
  32.  
  33. }
  34. if (motor2speed < 0)
  35. {
  36. motor2speed *= -1;
  37. motor2.setSpeed(motor2speed)
  38.  
  39. motor2.run(BACKWARD);
  40.  
  41. }
  42.  
  43. else
  44. {
  45. motor1speed *=-1
  46.  
  47. motor1.setSpeed(motor1speed);
  48. motor1.run(BACKWARD);
  49.  
  50.  
  51. }
  52.  
  53.  
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement