I’m trying to make a loop where a motor will run and lights will cycle indefinitely as long as the button is not pressed yet when the while(SensorValue[bump]==0) will only run once even if the button isn’t pressed.
#pragma config(Sensor, dgtl2, bump, sensorNone)
#pragma config(Sensor, dgtl10, green, sensorLEDtoVCC)
#pragma config(Sensor, dgtl11, red, sensorLEDtoVCC)
#pragma config(Sensor, dgtl12, amber, sensorLEDtoVCC)
#pragma config(Motor, port2, fan,tmotorVex393_MC29, openLoop)
task main()
{
while(true){
untilBump(bump); //waits until button is pressed
while(SensorValue(bump)==0){
startMotor(fan,127); //startmotor
turnLEDOn(green); //turn green on
delay(2000);
turnLEDOff(green); //turn green off
turnLEDOn(amber); //turn amber on
delay(2000);
turnLEDOff(amber); //turn amber off
turnLEDOn(red); //turn red on
delay(2000);
turnLEDOff(red); //turn red off
}
stopMotor(fan);
}
}