Advertisement
Guest User

Untitled

a guest
May 29th, 2015
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. int thresh= 100000;
  2. int distance = 0;
  3.  
  4. sub checkdistance()
  5. {
  6. if(SensorUS(IN_1) < thresh)
  7. {
  8. thresh = SensorUS(IN_1);
  9. distance = MotorRotationCount(OUT_A);
  10. }
  11. }
  12.  
  13.  
  14. task main ()
  15. {
  16. SetSensorLowspeed(IN_1);
  17. SetSensorTouch(IN_3);
  18. repeat(144)
  19. {
  20. RotateMotorEx(OUT_A, 70, 10, 0, false, false);
  21. Wait(50);
  22. checkdistance();
  23. }
  24. RotateMotorEx(OUT_A, 40, distance, 0, false, true);
  25. Wait(100);
  26. while(SENSOR_3 == 0)
  27. {
  28. OnFwdSync(OUT_AC, 75, 0);
  29. }
  30. Off(OUT_AC);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement