Sebastian1314

Basketball Drills - ROBOTC

Dec 7th, 2011
785
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Robots 1.69 KB | None | 0 0
  1. //Basketball Drills [IN PROGRESS] by Sebastian1314 and Steve Von Fedak
  2.  
  3. #pragma config(Sensor, in2,    rEnc,                sensorQuadEncoder, int5)
  4. #pragma config(Sensor, in3,    lEnc,                sensorQuadEncoder, int6)
  5. #pragma config(Motor,  port2,           rMotor,        tmotorNormal, openLoop)
  6. #pragma config(Motor,  port3,           lMotor,        tmotorNormal, openLoop)
  7. #pragma config(Motor,  port6,           topMotor,      tmotorNormal, openLoop)
  8. //*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//
  9.  
  10. void initProg(int waitTime)
  11. {
  12.     wait1Msec(waitTime);
  13.     bMotorReflected[rMotor] = 1;
  14. }
  15.  
  16. void resetEncoders()
  17. {
  18.     SensorValue[lEnc] = 0;
  19.     SensorValue[rEnc] = 0;
  20. }
  21.  
  22. void moveForward(int rotationLength)
  23. {
  24.   while(SensorValue[rEnc] >= (rotationLength*-1))
  25.     {
  26.       if(SensorValue[lEnc] == SensorValue[rEnc])
  27.         {
  28.           motor[port3] = 63;
  29.           motor[port2] = 63;
  30.         }
  31.         else if(SensorValue[lEnc] < SensorValue[rEnc])
  32.         {
  33.           motor[port3] = 43;
  34.           motor[port2] = 63;
  35.         }
  36.         else
  37.         {
  38.           motor[port3] = 63;
  39.           motor[port2] = 43;
  40.         }
  41.     }
  42. }
  43.  
  44. void moveBackwards  (int rotationLength)
  45. {
  46.   while(SensorValue[rEnc] <= rotationLength)
  47.     {
  48.       if(SensorValue[lEnc] == SensorValue[rEnc])
  49.         {
  50.           motor[port3] = -63;
  51.           motor[port2] = -63;
  52.         }
  53.         else if(SensorValue[lEnc] > SensorValue[rEnc])
  54.         {
  55.           motor[port3] = -43;
  56.           motor[port2] = -63;
  57.         }
  58.         else
  59.         {
  60.           motor[port3] = -63;
  61.           motor[port2] = -43;
  62.         }
  63.     }
  64. }
  65.  
  66. task main()
  67. {
  68.   initProg(2000);
  69.   resetEncoders();
  70.  
  71.   moveForward(1200) ; resetEncoders();
  72.  
  73.   moveBackwards(900); resetEncoders();
  74.  
  75.   moveForward(2200) ; resetEncoders();
  76.  
  77.   moveBackwards(2150); resetEncoders();
  78. }
  79.  
  80.  
Advertisement
Add Comment
Please, Sign In to add comment