I made a circuit where when I press a button, a LED lights up using a pull-down resistor. But when I tried the same with a pull-up resistor instead, the LED remains off (whereas I expected it to be on by default and go off when I push the button). What is the problem?
Here is the circuit:
And here the code:
int BUTTON = 7;
int LED = 8;
void setup()
{
pinMode(BUTTON, INPUT);
pinMode(LED, OUTPUT);
}
void loop()
{
digitalWrite(LED, digitalRead(BUTTON));
}
