Else Statement is being Ignored

Hey all, I wrote this code but the else statement is being ignored and I can’t figure out why. It’s not an issue with the sensor because I see the value of the bumpSwitch change in my sensor windows. If anybody could give me some pointers or advice that would be great., thanks!

task main()
{
while(1==1)
{
if(SensorValue[bumpSwitch==0])
{
startMotor(leftMotor,63);
startMotor(rightMotor,63);
}
else
{
stopMotor(leftMotor);
stopMotor(rightMotor);
}
}
}

if(SensorValue[bumpSwitch==0])

It looks like you have the bracket in the wrong place. You probably want this instead:

if(SensorValue[bumpSwitch]==0)
8 Likes

Thanks so much! It worked :slight_smile: