HTML

[PROJECT] clawbot.c

Nov 16th, 2017
329
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.28 KB | None | 0 0
  1. #pragma config(Sensor, in1,    fright,         sensorLineFollower)
  2. #pragma config(Sensor, in2,    fleft,          sensorLineFollower)
  3. #pragma config(Sensor, in3,    lightsensor,    sensorReflection)
  4. #pragma config(Sensor, dgtl1,  red,            sensorLEDtoVCC)
  5. #pragma config(Sensor, dgtl2,  yellow,         sensorLEDtoVCC)
  6. #pragma config(Sensor, dgtl3,  green,          sensorLEDtoVCC)
  7. #pragma config(Sensor, dgtl4,  touchclaw,      sensorTouch)
  8. #pragma config(Sensor, dgtl5,  sonar,          sensorSONAR_inch)
  9. #pragma config(Motor,  port1,           mleft,         tmotorVex393_HBridge, openLoop)
  10. #pragma config(Motor,  port3,           headlight,     tmotorVexFlashlight, openLoop, reversed)
  11. #pragma config(Motor,  port6,           mclaw,         tmotorVex393_MC29, openLoop)
  12. #pragma config(Motor,  port7,           marm,          tmotorVex393_MC29, openLoop)
  13. #pragma config(Motor,  port10,          mright,        tmotorVex393_HBridge, openLoop)
  14. //*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//
  15.  
  16. task main()
  17. {
  18.     turnLEDOff(green);
  19.     turnLEDOff(yellow);
  20.     turnLEDOff(red);
  21.     while(1==1)
  22.     {
  23.         while(SensorValue(lightsensor)<501)
  24.         {
  25.             turnFlashlightOff(headlight);
  26.             if(SensorValue(fleft)>1000)
  27.             {
  28.                 turnLEDOff(green);
  29.                 turnLEDOn(yellow);
  30.                 startMotor(mleft,-32);
  31.                 startMotor(mright,-50);
  32.             }
  33.             if(SensorValue(fright)>1000)
  34.             {
  35.                 turnLEDOff(green);
  36.                 turnLEDOn(red);
  37.                 startMotor(mleft,50);
  38.                 startMotor(mright,32);
  39.             }
  40.             else
  41.             {
  42.                 turnLEDOn(green);
  43.                 turnLEDOff(yellow);
  44.                 startMotor(mleft,-32);
  45.                 startMotor(mright,32);
  46.             }
  47.         }
  48.         if(SensorValue(touchclaw)>0)
  49.         {
  50.             turnLEDOff(green);
  51.             turnLEDOn(yellow);
  52.             turnLEDOff(red);
  53.             turnFlashlightOn(headlight,-127);
  54.             stopMotor(mleft);
  55.             stopMotor(mright);
  56.             startMotor(mclaw,-32);
  57.             wait(1);
  58.             stopMotor(mclaw);
  59.             turnLEDOn(green);
  60.             turnLEDOff(yellow);
  61.             startMotor(mleft,90);
  62.             startMotor(mright,-90);
  63.             wait(5);
  64.             stopMotor(mleft);
  65.             stopMotor(mright);
  66.             while(1==1)
  67.             {
  68.                 turnFlashlightOff(headlight);
  69.                 if(SensorValue(sonar)<7.5) // inches
  70.                 {
  71.                     turnLEDOn(green);
  72.                     turnLEDOff(yellow);
  73.                     stopMotor(mleft);
  74.                     stopMotor(mright);
  75.                     startMotor(marm,-100);
  76.                     wait(2.25);
  77.                     stopMotor(marm);
  78.                     startMotor(mclaw,32);
  79.                     wait(1);
  80.                     turnLEDOn(yellow); // victory screech
  81.                     turnLEDOn(red);
  82.                     wait(0.5);
  83.                     turnLEDOff(green);
  84.                     turnLEDOff(yellow);
  85.                     turnLEDOff(red);
  86.                     wait(0.5);
  87.                     turnLEDOn(green);
  88.                     turnLEDOn(yellow);
  89.                     turnLEDOn(red);
  90.                     wait(0.5);
  91.                     turnLEDOff(green);
  92.                     turnLEDOff(yellow);
  93.                     turnLEDOff(red);
  94.                     wait(0.5);
  95.                     turnLEDOn(green);
  96.                     turnLEDOn(yellow);
  97.                     turnLEDOn(red);
  98.                     wait(0.5);
  99.                     turnLEDOff(green);
  100.                     turnLEDOff(yellow);
  101.                     turnLEDOff(red);
  102.                     wait(0.5);
  103.                     turnLEDOn(green);
  104.                     turnLEDOn(yellow);
  105.                     turnLEDOn(red);
  106.                     stopAllTasks();
  107.                 }
  108.                 else
  109.                 {
  110.                     turnLEDOff(green);
  111.                     turnLEDOn(yellow);
  112.                     turnLEDOff(red);
  113.                     startMotor(mleft,32);
  114.                     startMotor(mright,-32);
  115.                 }
  116.             }
  117.         }
  118.         else
  119.         {
  120.             turnLEDOn(green);
  121.             turnLEDOff(yellow);
  122.             turnLEDOff(red);
  123.             turnFlashlightOn(headlight,-127);
  124.             startMotor(mleft,-32);
  125.             startMotor(mright,32);
  126.         }
  127.     }
  128. }
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment