I'm trying to help my 10 year old son with a project and I know nothing about C++.
We want to cycle a motor if the temp >= 80 degrees and reverse the motor if the temp <= 80 degrees. I tried to create a variable that toggled based on whether the motor had run or not. I keep getting the following error:
"exit status 1
lvalue required as left operand of assignment"
What does that mean? When I search for that error in other topics, I don't even understand the issues they're dealing with. I've tried reading through Language Reference page but I still can't piece it together.
Here's the portion of the code that keeps getting errors:
{
if (temp >= 80 && RunVariable = 0); //temperature equal or above 80F
small_stepper.setSpeed(500); //Max seems to be 500
Steps2Take = 2048; // Rotate CW
small_stepper.step(Steps2Take);
delay(2000);
RunVariable = 1;
break;
}
{
if (temp <= 80 && RunVariable = 1); //temperature equal or above 80F
(small_stepper.setSpeed(500)); //Max seems to be 500
Steps2Take = -2048; // Rotate CCW
small_stepper.step(Steps2Take);
delay(2000);
RunVariable = 0;
break;
}
If you have an answer, please explain like I'm a complete newbie (which I am). Thank you!
Deva_Rishi:
and return 'true' as a test value (assignments always do) mind you, this code does compile though doesn't it ?
In the case of if (RunVariable = 0), no, the assignment returns 0, or a "false" test value. An assignment always "returns" the value that's assigned to the variable.
You can get explanations and examples (not Arduino oriented but still useful) of the instructions and language usage at http://www.cplusplus.com/reference/