Hello, as i was practicing my coding with INPUTs and push buttons i realized that my push buttons aren't registered by an arduino. I thought that it was wiring problem but i have triplechecked my wiring and nothing was of. I also have pull down resistor (10k) connected to ground. The code is very simple. Here it is:
Unless the switch wiring is long enough to pick up noise, then an, external, lower value pull up resistor (strong pullup) may be required along with the capacitor to form a low pass filter.
Just to be pedantic @groundFungus, could you H-flip your diagram so action flows from left to right ?
Maybe you can add the LED shown left-to-right as well ?
1. The following diagram (Fig-1) describing the structure of DPin-8 may help you to understand your coding mistake.
Figure-1:
2. You have written --
if (button == HIGH)
{
digitalWrite(led, HIGH);
}
3. Instead of writing the code of Step-2, you could write as --
set direction of DPin-8 as input without internal pull-up resistor but with external pull-down resistor.
if (logic value of DPin-8 with which Button is connected is HIGH) //Button must have pull-down resistor
{
then ignite LED connected at DPin-3
}
4. The Arduino code for the argument of if() structure of Step-3 is:
6. In Fig-1, we observe that the input line (DPin-8) has an internal pull-up resistor (Rip). If we like to use it instead of an external pull-down, then the Button connection would appear as follows (Fig-2):
Figure-2:
7. Now, the code to detect the closed condition of Button would be:
pinMode(8, INPUT_PULLUP); //Rip is connected/enabled; G0OB is OFF
if(digitalRead(8) == LOW)
{
digitalWrite(led, HIGH);
}