HTML

1.5.6JacobHoward.c

Mar 29th, 2019
788
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.75 KB | None | 0 0
  1. #pragma config(Sensor, in1,    lineFollower,   sensorLineFollower)
  2. #pragma config(Sensor, in2,    potentiometer,  sensorPotentiometer)
  3. #pragma config(Sensor, in3,    lightSensor,    sensorReflection)
  4. #pragma config(Sensor, dgtl1,  limitSwitch,    sensorTouch)
  5. #pragma config(Sensor, dgtl2,  bumpSwitch,     sensorTouch)
  6. #pragma config(Sensor, dgtl3,  quad,           sensorQuadEncoder)
  7. #pragma config(Sensor, dgtl5,  sonar,          sensorSONAR_cm)
  8. #pragma config(Sensor, dgtl12, green,          sensorLEDtoVCC)
  9. #pragma config(Motor,  port1,           flashlight,    tmotorVexFlashlight, openLoop, reversed)
  10. #pragma config(Motor,  port2,           rightMotor,    tmotorVex393_MC29, openLoop)
  11. #pragma config(Motor,  port3,           leftMotor,     tmotorVex393_MC29, openLoop)
  12. #pragma config(Motor,  port9,           servoMotor,    tmotorServoStandard, openLoop)
  13. //*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//
  14.  
  15. task main()
  16. {
  17. /*
  18. while(1 == 1)
  19. {
  20.    if (SensorValue(lightSensor)>700)
  21.    {
  22.       turnFlashlightOn(flashlight, 127);
  23.    }
  24.    else
  25.    {
  26.       turnFlashlightOff(flashlight);
  27.    }
  28. }
  29. // if/else may be preferable because this way the true condition doesn't need to be rewritten backwards to allow function
  30. */
  31.  
  32. /*
  33. while(1 == 1)
  34. {
  35.     while(SensorValue(limitSwitch)==1)
  36.         {
  37.             if(SensorValue(lightSensor)>700)
  38.             {
  39.                 turnFlashlightOn(flashlight, 127);
  40.             }
  41.             else
  42.             {
  43.                 turnFlashlightOff(flashlight);
  44.             }
  45.         }
  46. }
  47. */
  48.  
  49. /*
  50. while(1 == 1)
  51. {
  52.     if(SensorValue(bumpSwitch)==1)
  53.     {
  54.         turnLEDOn(green);
  55.         wait(.05);
  56.         turnLEDOff(green);
  57.         wait(.05);
  58.     }
  59.     else
  60.     {
  61.         turnLEDOff(green);
  62.     }
  63. }
  64. */
  65.  
  66. /*
  67. while(1 == 1)
  68. {
  69.     while(SensorValue(bumpSwitch)==1)
  70.     {
  71.         if(SensorValue(sonar)>20)
  72.         {
  73.             startMotor(leftMotor, 63);
  74.         }
  75.         else
  76.         {
  77.             startMotor(leftMotor, -63);
  78.         }
  79.     }
  80.     stopMotor(leftMotor);
  81. }
  82. */
  83.  
  84. /*
  85. while(1 == 1)
  86. {
  87.     if(SensorValue(lineFollower)>2000)
  88.     {
  89.         setServo(servoMotor, 127);
  90.     }
  91.     else
  92.     {
  93.         setServo(servoMotor, -127);
  94.     }
  95. }
  96. */
  97.  
  98. /*
  99. while(1 == 1)
  100. {
  101.     if(SensorValue(bumpSwitch)==1)
  102.     {
  103.         if(SensorValue(lineFollower)>2000)
  104.         {
  105.             setServo(servoMotor, 127);
  106.         }
  107.         else
  108.         {
  109.             setServo(servoMotor, -127);
  110.         }
  111.     }
  112.     else
  113.     {
  114.         setServo(servoMotor, 0);
  115.     }
  116. }
  117. */
  118.  
  119. /*
  120. while(1 == 1)
  121. {
  122.     if(SensorValue(bumpSwitch)==1)
  123.     {
  124.         startMotor(leftMotor, 63);
  125.     }
  126.     else
  127.     {
  128.         stopMotor(leftMotor);
  129.     }
  130.     if(SensorValue(limitSwitch)==1)
  131.     {
  132.         startMotor(rightMotor, 63);
  133.     }
  134.     else
  135.     {
  136.         stopMotor(rightMotor);
  137.     }
  138. }
  139. */
  140.  
  141. /*
  142. 1. We didn't seem to encounter any issues in programming this.
  143. 2. If else loops make sense where two seperate states are required based on one condition, while loops would be more useful for a boolean application only requiring an on or off action.
  144. */
  145. }
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment