Why light delay is 5 second in arduino?

My code :

int pin = 8;
int pout = 12;
int result=0;
void setup() {
  pinMode(pin, INPUT);
  pinMode(pout, OUTPUT);  

void loop() {

  result = digitalRead(pin);

  if(result == 1)
    digitalWrite(pout, HIGH); 
  if(result == 0)
    digitalWrite(pout, LOW); 


I have set delay 1 sec but whenever i put high voltage on pin 8 The LED glow for 5 second. why?

How to set delay to none ? means whenever the pin 8 is HIGH the LED will glow else off.


There is no reason for the led to stay on for 5 seconds. It should stay on for one second.

How have you wired your button? Have you used a pull-down resistor? If not, your input pin is “floating” and will not work reliably.

If you wire the button between the input pin and ground, you can use INPUT_PULLUP and you will not need a resistor. When the button is pressed, the result will be LOW.


Do you have a standard Arduino board? Something non-standard may have the clock set incorrectly so the conversion factors inside delay() are incorrect.

The way that code is written, the LED will stay on for “at least” 1 second once it sees a high input.
If the input continues to remain high, the Led will continue to remain on until the input goes low.

Is the high signal a momentary pulse or is on for a longer period - say 5 seconds?