I have connected my LCD with arduino uno. I am controlling contrast with the library and not the potentiometer. I am trying to read input from the button, it is connected to pin 9 of arduino. The resistor in the image is grounded, now arduino is not sensing signal from the button it keeps printing this even though in the timestamp below I have not touched the button. The resistor is 1k ohm.
20:03:30.808 -> button not pressed
20:03:31.816 -> button pressed
20:03:32.798 -> button pressed
20:03:33.827 -> button not pressed
20:03:34.821 -> button pressed
20:03:35.849 -> button not pressed
20:03:36.847 -> button not pressed
20:03:37.842 -> button pressed
#include <LiquidCrystal.h>
const int buttonNumPad1 = 9;
int buttonNumPad1State = 0;
int Contrast = 127.5;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup()
{
Serial.begin(9600);
pinMode(buttonNumPad1State, INPUT);
analogWrite(6, Contrast);
lcd.begin(16, 2);
}
void loop()
{
buttonNumPad1State = digitalRead(buttonNumPad1);
if (buttonNumPad1State == HIGH){
Serial.println("button pressed");
lcd.setCursor(0, 1);
lcd.print("pressed");
} else {
Serial.println("button not pressed");
}
lcd.setCursor(0, 0);
lcd.print("Hello");
delay(1000);
lcd.clear();
}
Top view of my breadboard
is it something related to? https://docs.arduino.cc/learn/microcontrollers/digital-pins
Input pins make extremely small demands on the circuit that they are sampling, equivalent to a series resistor of 100 megohm in front of the pin. This means that it takes very little current to move the input pin from one state to another


