Sebastian1314

Maze Program Using Functions - ROBOTC

Dec 7th, 2011
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Robots 0.94 KB | None | 0 0
  1. /*
  2. ** MAZE PROGRAM 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 moveStraight(int timeInt)
  25. {
  26.   bMotorReflected[port2]= 1;
  27.   motor[port2] = 123;
  28.   motor[port3] = 126;
  29.   wait1Msec(timeInt);
  30. }
  31.  
  32. void StopWait(int timeInt)
  33. {
  34.   motor[port2] = 0;
  35.   motor[port3] = 0;
  36.   wait1Msec(timeInt);
  37.  
  38. }
  39. task main
  40. {
  41.   bMotorReflected[port2]= 1;
  42.   StopWait(1000);
  43.  
  44.   moveStraight(1000);
  45.   StopWait(1000);
  46.  
  47.   turnLeft(360);
  48.   StopWait(1000);
  49.  
  50.   moveStraight(1150);
  51.   StopWait(1000);
  52.  
  53.   turnRight(400);
  54.   StopWait(1000);
  55.  
  56.   moveStraight(620);
  57.   StopWait(1000);
  58.  
  59.   turnRight(420);
  60.   StopWait(1000);
  61.  
  62.   moveStraight(500);
  63.   StopWait(1000);
  64. }
  65.  
  66.  
Advertisement
Add Comment
Please, Sign In to add comment