Help with Trigger Box Project

I am currently trying to design a small very basic trigger box to output a 5v pulse at different times, that are selectable by a switch. Currently I am having difficulty with getting one time to function correctly.

I have an LED flashing every 1 second when a switch applies 5v to digital pin 7.

My issue is, when 5v is removed from pin 7 the light still flashes, there is no voltage at all on this pin as I have measured it with a multimeter.

I am using a Arduino Nano Everyday

Any help appreciated ??

#define OneSec 7
int TTL1 = 2;
 


void setup() {
 pinMode(TTL1, OUTPUT);
 pinMode(OneSec, INPUT);

}

void loop() {

  if(digitalRead(OneSec) == HIGH){
  digitalWrite(TTL1, HIGH);  
  delay(100);                      
  digitalWrite(TTL1, LOW);    
  delay(900);
  }

}

Sounds like you have a floating input. An input you are using must never be left unconnected, it has to be connect to a high or low voltage either directly or through a resistor.

The proper way to do this is to connect your switch between the input and ground and enable the internal pull up resistor when you use the pinMode call using INPUT_PULLUP.

Thanks Mike that worked a treat