Advertisement
Guest User

Untitled

a guest
Feb 20th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. #pragma config(StandardModel, "RVW Anemobot")
  2. //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
  3.  
  4. /*
  5. Project Title: Ruines of atlantis
  6. Name: Mikko Taitague
  7. Date:
  8.  
  9.  
  10. Task Description:
  11.  
  12.  
  13. Pseudocode:
  14.  
  15.  
  16. */
  17. void forward(float distance, int speed);
  18. void backward(float distance, int speed);
  19. void turn(float angle, int speed);
  20. void gotowall(float distance, int speed);
  21.  
  22.  
  23.  
  24.  
  25. task main()
  26. { //Program begins, insert code within curly braces}
  27. backward(0.56,45);
  28. forward(1.2,70);
  29. turn(90,35);
  30. forward(0.33,45);
  31. backward(0.33,45);
  32. turn(-90,35);
  33. forward(0.38,70);
  34. turn(-90,35);
  35. gotowall(0.30,80);
  36. turn(117,40);
  37. forward(2.23,90);
  38. turn(55,50);
  39. backward(0.51,45);
  40. forward(1.63,80);
  41. turn(-90,55);
  42. forward(1.09,75);
  43. turn(90,55);
  44. forward(0.95,80);
  45. turn(90,65);
  46. forward(0.45,60);
  47. backward(0.45,60);
  48. turn(-90,60);
  49. forward(0.7,75);
  50. turn(90,75);
  51. forward(1.75,90);
  52.  
  53.  
  54.  
  55. }
  56. void forward(float distance, int speed)
  57. {
  58. SensorValue[leftEncoder]=0;
  59. while(SensorValue[leftEncoder]<distance*1000)
  60. {
  61. motor[leftMotor] = speed;
  62. motor[rightMotor] = speed;
  63. }
  64. motor[leftMotor] = 0;
  65. motor[rightMotor] = 0;
  66.  
  67. }
  68. void backward(float distance, int speed)
  69. {
  70. SensorValue[leftEncoder]=0;
  71. while(SensorValue[leftEncoder]>-distance*1000)
  72. {
  73. motor[leftMotor] = -speed;
  74. motor[rightMotor] = -speed;
  75. }
  76. motor[leftMotor] = 0;
  77. motor[rightMotor] = 0;
  78.  
  79. }
  80. void turn(float angle, int speed)
  81. {
  82. float target = SensorValue[gyro] + angle*10;
  83. if(angle>0)//turn right gyro increases
  84. {
  85. while(SensorValue[gyro]<target)
  86. {
  87. motor[leftMotor] = speed;
  88. motor[rightMotor] = -speed;
  89. }
  90. }else //turn left gyro decreases
  91. {
  92. while(SensorValue[gyro]>target)
  93. {
  94. motor[leftMotor] = -speed;
  95. motor[rightMotor] = speed;
  96. }
  97. } motor[leftMotor] = 0;
  98. motor[rightMotor] = 0;
  99. }
  100. void gotowall(float distance, int speed)
  101. {
  102. while(SensorValue[sonarSensor]>distance*100)
  103. {
  104. motor[leftMotor] = speed;
  105. motor[rightMotor] = speed;
  106. }
  107. motor[leftMotor] = 0;
  108. motor[rightMotor] = 0;
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement