Motor not spinning when bump switch is pressed

Here is my code.

Taskmain()
{
if(SensorValue[bump]==1)
{
motor[test] = 127;
}
else
{
motor[test] = 0;
}
}
}

What have I done wrong?

1 Like

It doesn’t look like you have it in a while loop. You want to keep on checking the state of the bump. The way you have it now, the code will check for the state of the bumper once, and if it isn’t pressed, will set the motor to zero and be done.

3 Likes

Thanks for the help!

1 Like