Help with this code please!

[SOLVED]

So what's happening is that only the first if condition in the code is working. It seems the arduino basically ignores the second if statement, no matter the contents or the hardware. I'm a newbie to arduino, so please help me with this.

Steps I took:

  1. Interchanged the buttons to make sure it wasnt a faulty one, it wasnt.
  2. Changed the button(from one to two) in the first statement and two to one in the second statement, now the other button works but the first one doesnt.
  3. Tried replacing the second if with else if, still no good.

Any help greatly appreciated…

Thanks a lot!!

Edit: The pic of the code didnt get attached somehow, so here:

int val = 0; void setup() { Serial.begin(9600); pinMode(4, INPUT); pinMode(2, INPUT); } void loop() { int one = digitalRead(2); int two = digitalRead(4); if (two == LOW){ val -= 1; } else if (one = LOW){ val += 1; } Serial.println(val); } 

Touch here for the full post on the Arduino Apprentices tumblr

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s