Advertisement
Guest User

CODE

a guest
Dec 12th, 2017
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Robots 2.49 KB | None | 0 0
  1. #pragma config(Sensor, dgtl1,  leftEncoder,    sensorQuadEncoder)
  2. #pragma config(Sensor, dgtl3,  rightEncoder,   sensorQuadEncoder)
  3. #pragma config(Motor,  port1,           rightMotor,    tmotorVex393_HBridge, openLoop, reversed)
  4. #pragma config(Motor,  port10,          leftMotor,     tmotorVex393_HBridge, openLoop)
  5.  
  6.  
  7. task main()
  8. {
  9.     wait1Msec(2000);                                        //Robot waits for 2000 milliseconds before executing program
  10.  
  11.     SensorValue[rightEncoder] = 0;            //Set the encoder so that it starts counting at 0
  12.   SensorValue[leftEncoder] = 0;
  13.  
  14.   while(SensorValue(rightEncoder) < 3800)   //While rightEncoder has counted less than 1800 counts
  15.     {
  16.  
  17.         motor[rightMotor] = 115;                          //Motor on port2 is run at full (127) power forward
  18.         motor[leftMotor]  = 115;                        //Motor on port3 is run at full (-127) power reverse
  19.     }
  20.  
  21.      motor[rightMotor] = 0;
  22.      motor[leftMotor]  = 0;
  23.     SensorValue[rightEncoder] = 0;           
  24.   SensorValue[leftEncoder] = 0;
  25.  
  26.   wait1Msec(1000);
  27.  
  28.   while(SensorValue(rightEncoder) < 870)    //While leftEncoder has counted less than 1800 counts
  29.     {
  30.  
  31.         motor[rightMotor] = 93;                     //Motor on port2 is run at full (-127) power reverse
  32.         motor[leftMotor]  = -27;                        //Motor on port3 is run at full (127) power forward
  33. }
  34.  
  35.      motor[rightMotor] = 0;
  36.      motor[leftMotor]  = 0;
  37.     SensorValue[rightEncoder] = 0;           
  38.   SensorValue[leftEncoder] = 0;
  39.  
  40.  
  41.      wait1Msec(1000);
  42.  
  43.   while(SensorValue(rightEncoder) < 300)   //While rightEncoder has counted less than 1800 counts
  44.     {
  45.  
  46.         motor[rightMotor] = 90;                       //Motor on port2 is run at full (127) power forward
  47.         motor[leftMotor]  = 90;    
  48.  
  49.   }
  50.  
  51.  
  52.      motor[rightMotor] = 0;
  53.      motor[leftMotor]  = 0;
  54.     SensorValue[rightEncoder] = 0;           
  55.   SensorValue[leftEncoder] = 0;
  56.  
  57.   wait1Msec(1000);
  58.  
  59.   while(SensorValue(rightEncoder) < 670)    //While leftEncoder has counted less than 1800 counts
  60.     {
  61.  
  62.         motor[rightMotor] = 93;                     //Motor on port2 is run at full (-127) power reverse
  63.         motor[leftMotor]  = -27;                        //Motor on port3 is run at full (127) power forward
  64. }
  65.  
  66.      motor[rightMotor] = 0;
  67.      motor[leftMotor]  = 0;
  68.     SensorValue[rightEncoder] = 0;           
  69.   SensorValue[leftEncoder] = 0;
  70.  
  71.  
  72.   wait1Msec(1000);
  73.  
  74.   while(SensorValue(rightEncoder) < 3900)   //While rightEncoder has counted less than 1800 counts
  75.     {
  76.  
  77.         motor[rightMotor] = 110;                          //Motor on port2 is run at full (127) power forward
  78.         motor[leftMotor]  = 110;       
  79.  
  80.   }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement