Sebastian1314

Maze Program v2 Using Functions - ROBOTC

Dec 7th, 2011
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. ** MAZE PROGRAM v2 USING FUNCTIONS
  3. **
  4. **By Sebastian1314 and Steve Von Fedak
  5. **
  6. */
  7.  
  8. void turnRight(int timeInt)
  9. {
  10.   bMotorReflected[port2]= 1;
  11.   motor[port2] = -123;
  12.   motor[port3] = 126;
  13.   wait1Msec(timeInt);
  14. }
  15.  
  16. void turnLeft(int timeInt)
  17. {
  18.   bMotorReflected[port2]= 1;
  19.   motor[port2] = 123;
  20.   motor[port3] = -126;
  21.   wait1Msec(timeInt);
  22. }
  23.  
  24. void uTurn()
  25. {
  26.   bMotorReflected[port2]= 1;
  27.   motor[port2] = 123;
  28.   motor[port3] = -126;
  29.   wait1Msec(850);
  30. }
  31.  
  32. void moveStraight(int timeInt)
  33. {
  34.   bMotorReflected[port2]= 1;
  35.   motor[port2] = 123;
  36.   motor[port3] = 126;
  37.   wait1Msec(timeInt);
  38. }
  39.  
  40. void StopWait(int timeInt)
  41. {
  42.   motor[port2] = 0;
  43.   motor[port3] = 0;
  44.   wait1Msec(timeInt);
  45. }
  46.  
  47. task main
  48. {
  49.   bMotorReflected[port2]= 1;
  50.   StopWait(2000);
  51.  
  52.   moveStraight(1000);
  53.   StopWait(1000);
  54.  
  55.   turnLeft(360);
  56.   StopWait(1000);
  57.  
  58.   moveStraight(1150);
  59.   StopWait(1000);
  60.  
  61.   turnRight(400);
  62.   StopWait(1000);
  63.  
  64.   moveStraight(620);
  65.   StopWait(1000);
  66.  
  67.   turnRight(420);
  68.   StopWait(1000);
  69.  
  70.   moveStraight(500);
  71.   StopWait(2000);
  72.  
  73.   uTurn();
  74.   StopWait(1000);
  75.  
  76.   moveStraight(500);
  77.   StopWait(1000);
  78.  
  79.   turnLeft(380);
  80.   StopWait(1000);
  81.  
  82.   moveStraight(540);
  83.   StopWait(1000);
  84.  
  85.   turnLeft(380);
  86.   StopWait(1000);
  87.  
  88.   moveStraight(1150);
  89.   StopWait(1000);
  90.  
  91.   turnRight(400);
  92.   StopWait(1000);
  93.  
  94.   moveStraight(1000);
  95.   StopWait(1000);
  96.  
  97.   uTurn();
  98.   StopWait(1000);
  99. }
Advertisement
Add Comment
Please, Sign In to add comment