My Arduino NANO lost COMs when I uploaded a new rev sketch using A4 analog port.

I feel my Arduino NANo lost COM ports when I uploaded a new revision sketch using A4 as analog input pin instead A3 of the previous one.

Before, I could correctly communicate with Arduino NANO via USB port until I uploaded a sketch that is using A4 (ADC4) as analog input port.
Now when I connect the USB NANO cable my PC does not show any USB port active at all.

This latest sketch revision I uploaded - which uses A4 pin - is working well but I currently cannot upload any new revision because I cannot comunicate with my NANO any more.

So:

  • Is there any way to avoid my current sketch starts so that a COM port will come up again and I can upload a correct previous sketch revision?
  • Is there any way, unless SPI port (i.e. using Arduino ISP board), to communicate again and upload the correct previous sketch?
  • If I will use SPI to upload it will NANO loose its bootloader?

Thanks for the attention.

On a nano, there is nothing the sketch can do to prevent the port from showing up. The serial coms is provided by a dedicated USB-serial adapter. The port not appearing can only be caused by hardware or driver problems.

Is the power light on the nano on? If not, power is not getting to it. Could you have shorted out the power rails while handling it, causing the computer to turn off the USB port, or connected external hardware improperly resulting in same? Or maybe you have an excessive load connected to it (with the same result?)

Does the light blink when you press reset? If so, that confirms the '328p is running (to some extent, at least).

Are you using a different USB cable? There has been a plague of bad USB cables with the power connected, but the data lines not connected or poorly constructed such that the data lines break quickly in normal use.

Have you changed anything on the computer?

Thank you for your suggestions.

a) It seems I realized that A4 I am currently using is also the SDA line then I thought that togheter with A5/SCL line they has something to do with USB serial com. And the change in using analog input pin from A3 to A4 (because A3 input did not work any more) is the only difference between previous and current sketch version.

-b) The power light is on and when NANO is reseted (also by the switch) a blue light blinks few times and then a second red light lites steadly. But in such condition the sketch is not being executed.
Anyway when I power on the NANO using an external power (8Vcc at pins Vin&GND, and this will be the final configuration) the sketch works correclty (in this condition the second red light is blinking).
[Just in case, I read somewhere that the two power lines can conflict and NANO could be damaged, so I payed attention not to use both power methods at the same time; or at least I hope to always have done it! ]

c) Regarding the USB cable I always used the same. More, I can connect other Arduino-like microcontrollers using it and get serial com working well.

Anyway, today I found that even if the external power is powered off it overloads in some way the NANO so that its behaviour is as explained at point b).
When I phisically detached Vin pin the NANO has been reachable by the PC again.
So now the point is that I can communicate wiìth the NANO only if I detach the Vin pin from the external power supply, then it seems it is not sufficient that the external power supply being powered off while you are using USB cable to program Arduino NANO.

Finally, is not a problem for me the practice of 1) power-off the external power supply, 2) detach Vin pin, 3) attach the USB cable, 4) reprogram Arduino NANO, 5) detach USB, 6) re-attach the Vin pin, 7) power-on the external power supply and let the sketch work.

Maybe I will use a relay (driven by the external power supply) to automatically detach/attach the Vin pin.

Thank you to have driven my attention on power rails.

Most regulators have a diode in them to keep the output voltage from going too high above the input voltage. If the power supply draws current when it is off, but the output is powered, that would explain what you’re seeing. A diode between power supply and Vin (band towards Vin) would solve that.