# Quick question:

I'm not sure what this means:

stepperState = !stepperState;

does it mean stepperState is not equal to it's current state?

!= means not equal to, but not sure of =!

Thanks

It means reverse the state of stepperState. I.e. make stepperState equal to (not stepperState).

I hope stepperState is a boolean.

Steve

Thanks

paloian: does it mean stepperState is not equal to it's current state?

No, it means stepperState becomes equal to not its current state.

Assuming stepperState is a boolean, try:

``````stepperState ^= 1; // exclusive OR stepperState with 1 (flips it)
``````

Test:

``````void setup()
{
Serial.begin(9600);
}
void loop()
{
static bool stepperState = false;
stepperState ^= 1;
Serial.println(stepperState);
delay(1000);
}
``````

From his description you can not assume StepperState is boolean. xor'ing the value with a 1 will only flip the low order bit. Any value can equate to a true and doing !value will change it to 0, if the value is not zero, and to 1 if the value is zero.

Don't use XOR for booleans, doing the !value will assure you of a boolean result even if the value is non-boolean. If you want to store 32 booleans in a int32 variable, then use XOR to flip individual bits, but that is a different question.

``````void IsItTrue(int value)
{
if (value)
{
Serial.print("value is non zero: ");
Serial.print(value);
Serial.print("\r\n");
}
else
{
Serial.print("value is zero");
Serial.print("\r\n");
}
}

void setup() {
Serial.begin(115200);
int value = 99;
IsItTrue(value);

Serial.print("Not the value\r\n\r\n");
value = !value;
IsItTrue(value);

Serial.print("Not the value\r\n\r\n");
value = !value;
IsItTrue(value);
}

void loop() {

}
``````