State change without input change. (Leonardo)

I'm new to Ardunio, but this still should be really straightforward, so I'm not sure what's going on. I'm trying to make it turn on an LED when I connect a wire from pin 2 to pin 9, but when I try to upload the program the led turns on after 10 seconds regardless of pin 9's state. Help would be appreciated as to why this happens, and possible fixes, thanks

int led = 1;
int out1= 2;
int in1 = 9;
void setup()
{
  pinMode(led, OUTPUT);
  pinMode(out1, OUTPUT);
  pinMode(in1, INPUT);
}
void loop()
{

  digitalWrite(out1, HIGH);

  if (digitalRead(in1) == HIGH);
  {
    digitalWrite(led, HIGH);
  }
}

Is there a pull down resistor on your input? It could just be picking up noise.

I tried it with a resistor and it did not work, I'm not sure if I was clear on this, but even when the pin 9 is high, the led does not go high until 10 seconds after the program is uploaded.

I wonder is it a good idea to use pin1 as it is connected to the USART? Try a different pin for your led.

...R

This is NOT a software issue so provide a circuit diagram/ photo.

Mark

Congratulations! You just built an NFA.

Try using the Arduino's internal pullup resistors and play around with setting out1 to LOW. Also, switch the LED over to the onboard debugging LED - pin 13. That way you can test your code and your wiring separately.

In setup change:

pinMode(in, INPUT);

to:

pinMode(in1, INPUT_PULLUP);