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:

  pinMode(13, OUTPUT);
  pinMode(2, INPUT);

  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.


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.

  • @Supamiu alternatively (for testing) configure D2 as INPUT_PULLUP and connect it to ground with the jumper – Sim Son Aug 20 '20 at 8:56
  • So you mean I should have a jumper between D2 and GND, and use another jumper to connect +5V to D2 and observe the trigger on D2? – Supamiu Aug 20 '20 at 9:04
  • @Supamiu No, you should add a resistor between D2 and GND, not a jumper. A jumper would end up with a short circuit when you connect D2 to +5V. electronics-tutorials.ws/logic/pull-up-resistor.html – Majenko Aug 20 '20 at 9:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.