I wanted to make relay open by button that I can turn off and on.
It used digitalread().
It turned on instantly but then i had to wait some time (around 1 second).
So I changed to analogRead() to see what is happening.
After some observations i saw that when closing circuit it instantly went from around 250 to 1023 but when i opened circuit it slowly went back to around 250 (around 1 sec)
A pull-down resistor pulls the input low when the switch is off. When the switch is on, it "overpowers" the resistor and forces the input high (and then current flows through the resistor).
There is actually a built-in pull-up resistor that you can enable, so you don't need to add one. But you need to connect your switch to ground and reverse the logic in your code (or if it's a toggle switch you can turn it upside-down).