user68396: I have a Longruner Nano ATMega 328P (copy of arduino nano, main difference being the USB connector, CH340 instead of the usual FT232, from what I could find using google searches).
I wrote a super basic code to test its signal detection capabilities:
setup(){
  pinMode(13, OUTPUT);
  pinMode(2, INPUT);
}

loop(){
  digitalWrite(13, digitalRead(2));
}

Hard to make it simpler to test a simple thing: when I give a HIGH signal to D2, D13 is HIGH too.
To test it, I used a simple male-male jump cable and connected VIN pin to the D2 one, for a very brief moment. And I notice D13 stays HIGH for around a second (measured with serial, lowest I could get was 996ms after super quickly touching D2 with the jump cable).
I tried to change the pinMode to INPUT_PULLUP following a similar question I found, but it didn't change anything regarding this delay.
Am I doing something wrong? Maybe a wrong configuration? Or is this just a hardware issue due to the fact that I'm using a copy and there's more than just the USb connector that changes?
I can adapt and work with this if it's required, but being able to have an accurate signal detection would help me greatly.

user10794: Don't use Vin as a logic source. Use the +5V pin.
Also, disconnecting the pin is not the same as grounding it. It is "floating". For a proper test, connect a +5V to the pin, and follow it with a Gnd.
A floating pin has an undefined logic level.
What would work in your case is to have a (say) 1k resistor between D2 and Gnd. That way, the moment you disconnect the voltage input the "pull-down" resistor will return it to 0V.

68396: <p>I have a Longruner Nano ATMega 328P (copy of arduino nano, main difference being the USB connector, CH340 instead of the usual FT232, from what I could find using google searches).</p>
<p>I wrote a super basic code to test its signal detection capabilities:</p>
<pre><code>setup(){
  pinMode(13, OUTPUT);
  pinMode(2, INPUT);
}

loop(){
  digitalWrite(13, digitalRead(2));
}
</code></pre>
<p>Hard to make it simpler to test a simple thing: when I give a HIGH signal to D2, D13 is HIGH too.</p>
<p>To test it, I used a simple male-male jump cable and connected VIN pin to the D2 one, for a very brief moment. And I notice D13 stays HIGH for around a second (measured with serial, lowest I could get was 996ms after super quickly touching D2 with the jump cable).</p>
<p>I tried to change the pinMode to INPUT_PULLUP following a similar question I found, but it didn't change anything regarding this delay.</p>
<p>Am I doing something wrong? Maybe a wrong configuration? Or is this just a hardware issue due to the fact that I'm using a copy and there's more than just the USb connector that changes?</p>
<p>I can adapt and work with this if it's required, but being able to have an accurate signal detection would help me greatly.</p>
 10794: <p>Don't use Vin as a logic source. Use the +5V pin.</p>
<p>Also, disconnecting the pin is not the same as grounding it. It is &quot;floating&quot;. For a proper test, connect a +5V to the pin, and follow it with a Gnd.</p>
<p>A floating pin has an undefined logic level.</p>
<p>What would work in your case is to have a (say) 1k resistor between D2 and Gnd. That way, the moment you disconnect the voltage input the &quot;pull-down&quot; resistor will return it to 0V.</p>
