I’m having a problem with programming the Optical Sensor. My goal is to be able to use the red alliance Triball to exit the while not red loop. However when I program it there is no function call for the color functions. In the blocks version I define that I do need to stop to shut off colormode however that code doesn’t work in visual studio code extension.
Here is the Autonomous Code
Left_Front.setVelocity(80,percent);
Left_Back.setVelocity(80,percent);
Right_Back.setVelocity(80,percent);
Right_Front.setVelocity(80,percent);
IntakeLeft.setVelocity(80,percent);
//define start of Catapult movement
if (Triball_Detector.color(green)){
//Code to launch green triballs and to lower catapult
Catapult.spin(forward);
}
if (Triball_Detector.color(red)){
//code to launch Red Triball
Catapult.spin(forward);
drive forward(90);
}
else{
if (Catapult_Stop.pressing()){
Catapult.stop(hold);
}
}
Here is the Device Setup I haven’t changed the velocities in the beginning of the autonomous
//optical Sensor
optical Triball_Detector = optical(PORT14);
motor Catapult = motor(PORT14, ratio18_1,true);