# HELP! My variables do not change (I'm a beginner)

I am trying to change the value of the variable called "Do" with a switch called "low". When I flick the switch, I can see the value of "low" going from 0 to 1 but the value of Do doesn't change.

Can someone help me, I have about one month of experience...

int Do;
int low = 13;

void setup(){

pinMode(low,INPUT);

Serial.begin(9600);

}

void loop(){
Serial.println (Do);
delay(500);

if (low==1) ;
{ (Do=76);
}

if (low==0) ;
{ (Do=4);
}

}

Lose the semicolon after the if

This is NOT an installation and troubleshooting topic.

Thanks for the fast reply but it still do no work, my variable "Do" stays at 0...

Oops.
Will 13 ever equal 1?

You’re missing a digitalRead

TheMemberFormerlyKnownAsAWOL:
Oops.
Will 13 ever equal 1?

You're missing a digitalRead

I can see the value of "low" going from 0 to 1. 13 is the pin number.

Yes, you’re missing a digitalRead.

“low” has the value 13.
You’re comparing 13 to 1 and 13 to zero.
Neither is ever going to be true.

You don’t need two tests, a simple else would work just as well.

TheMemberFormerlyKnownAsAWOL:
Yes, you're missing a digitalRead.

"low" has the value 13.
You're comparing 13 to 1 and 13 to zero.
Neither is ever going to be true.

You don't need two tests, a simple else would work just as well.

I tried this and it still not working...

int Do;
int low = 13;

void setup(){

pinMode(low,INPUT);

Serial.begin(9600);

}

void loop(){
Serial.println (Do);
delay(500);

if (digitalRead(low),HIGH) { (Do=76);
}

if (digitalRead(low),LOW) { (Do=10);
}

}

The comma is not a comparison operator.

TheMemberFormerlyKnownAsAWOL:
The comma is not a comparison operator.

Thanks a lot it works now.

After a little cleaning:

``````const byte LowPin = 13;

void setup()
{
Serial.begin(115200);
pinMode(LowPin, INPUT);
}

void loop()
{
int input = digitalRead(LowPin);

if (input == HIGH)
Serial.println(76);
else
Serial.println(10);

delay(500);
}
``````

Worth noting that both "low" and do are very bad variable names - low differs only from LOW by case and Do from the do keyword only by case, and remember that people sometimes refer to pin 0 as D0 (digital pin 0)