multiple button

why this happen ...? when i pressed second button the voltage at led drop to 1v why but when i pressed first button it 5v..
plss help me.Someone...
this here my code

int buttonState = 0;
int buttonState2 = 0;
void setup()
{
pinMode(2, INPUT);
pinMode(3, INPUT);
pinMode(13, OUTPUT);
}

void loop()
{
// read the state of the pushbutton value
buttonState = digitalRead(2);
buttonState2 = digitalRead(3);
// check if pushbutton is pressed. if it is, the
// buttonState is HIGH
if (buttonState == HIGH)
{
// turn LED on
digitalWrite(13, HIGH);
}
if (buttonState2 == HIGH)
{
// turn LED on
digitalWrite(13, HIGH);
}

else
{
// turn LED off
digitalWrite(13, LOW);
}
delay(10); // Delay a little bit to improve simulation performance
}

for image download that below...

When you press the button connected to Pin2 it will turn the LED on but, because you have not pressed the button connected to Pin3 the ELSE clause will immediately turn it off again.

Try replacing the ELSE with

if (buttonState == LOW and buttonState2 == LOW)

...R

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom... :slight_smile: