Delay when digital pin switches from HIGH to LOW

I'd like to control the blink frequency of an LED using a single wire. I want to use digital pin 7 as the control pin. The default blink frequency should be 1000ms. When pin 7 is HIGH the frequency should be 100ms.

I thought I could start using the following sketch to implement this behavior:

void setup() {
Serial.begin(9600);
pinMode(7, INPUT);
}

void loop() {
Serial.println(digitalRead(7));
}

When I start the program it permanently outputs 0. When I connect the Arduino's 3V3 pin to digital pin 7 with a wire it prints 1 which is expected. Now for the part that I do not understand: When I disconnect pin 7 from 3V3 again the Arduino continues to output 1 for several seconds. After that it outputs 0 again. What causes the delay when pin 7 switches from HIGH to LOW again?

The behavior is different when I use the following sketch:

void setup() {
Serial.begin(9600);
pinMode(7, INPUT_PULLUP);
}

void loop() {
Serial.println(digitalRead(7));
}

When I now connect Arduino's GND to pin 7 the output changes immediately from 1 to 0. The opposite is also true, that is when I disconnect GND from pin 7, the output changes from 0 to 1 immediately.

This is because the input is "floating" - that is, it will randomly return either HIGH or LOW. That's why you need a pull-up or pull-down resistor in the circuit.

Thank you very much for your quick reply!

I assume I have to use the second solution (with INPUT_PULLUP and the GND signal), if I do not want to use an external resistor?

Yes, correct.