"= embedded in expression" warning when setting up a while loop

I’m working on a program for one of our projects that will spin a sign until a bump switch is activated. Once the bump switch is pressed again, the sign will start the while loop statement. This is the first program I’ve done so far with an infinite loop, and everything seems to be fine. but I keep getting a warning error on the while loop line.

Warning:Assignment ‘=’ embedded in expression

If it helps, here is my code.

task main()
{
while(SensorValue(bumpSwitch) = 1)

motor[signMotor] = 100;
}

Update: I looked at the sample code and realized I need to add a second equals sign, so my code now looks like the following.

task main()
{
while(SensorValue(bumpSwitch) == 1)

motor[signMotor] = 100;
}

My new question is, why does it need a second equals sign? What does it indicate to the program? I’m somewhat of a beginner so I’m less trying to figure out what works and more trying to understand why it works.

Thank you!

= and == are two different operators that accomplish different things. I’d recommend looking up a table of C operators.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.