Hello,
I’m trying to make the flashlight sensor work alongside with the claw. Whenever I run the code, the flashlight only works after I activate the claw. Does anyone know how to make both pieces of code run simultaneously?
Thank you,
Here is my code provided:
#pragma config(Sensor, in2, light, sensorAnalog)
#pragma config(Sensor, dgtl1, limitSwitch, sensorTouch)
#pragma config(Motor, port1, flashlight, tmotorVexFlashlight, openLoop, reversed)
#pragma config(Motor, port3, clawMotor, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port4, rotateMotor, tmotorVex393_MC29, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
task main()
{
while (1==1)
{
untilTouch(limitSwitch);
{
motor[clawMotor] = 50;
wait(0.5);
motor[clawMotor] = 0;
}
untilRelease(limitSwitch);
{
motor[clawMotor] = -50;
wait(0.5);
motor[clawMotor] = 0;
}
if(SensorValue(light) >=400)
{
turnFlashlightOn(flashlight, 127);
}
else if(SensorValue(light) <400)
{
turnFlashlightOff(flashlight);
}
}
}