I just recieved my Arduino board so I'm still trying simple stuff, so don't laugh :-/
I was trying to make a led light light up, whenever you press any of the 4 buttons, but when the program starts first there is a weak light, and when I press a button it lights up a little bit brighter. I just dont get it... I tell the board to keep the pin low when there are no buttons pressed. What is the problem?
Here is the code (the buttons are attached to pins 9-12 and the led is on 13):
int ledPin = 13;
int firstPin = 9;
int secondPin = 10;
int thirdPin = 11;
int fourthPin = 12;
int one = 0;
int two = 0;
int three = 0;
int four = 0;
void setup()
*{ *
- pinMode(ledPin, OUTPUT);*
- pinMode(firstPin, INPUT);*
- pinMode(secondPin, INPUT);*
- pinMode(thirdPin, INPUT);*
- pinMode(fourthPin, INPUT); *
}
void loop()
{
-
one = digitalRead(whtPin);*
-
two = digitalRead(bluPin);*
-
three = digitalRead(redPin);*
-
four = digitalRead(yelPin);*
-
if(one == HIGH || two == HIGH || three = HIGH || four = HIGH)*
-
{*
-
digitalWrite(ledPin, HIGH);*
-
}*
-
else { digitalWrite(ledPin, LOW);}*
}