Recently bought a nano clone and everything worked fine until i tried to power it with the help of a 9v battery by using the VIN and GND pins, i noticed that it was acting weird and upon using this code which tells me when the board runs setup, i found out that it was randomly resetting every couple of seconds.
Its not the power supply since i also tried it with a pair of 3.7v 2000 mA Lithium-ion batteries connected in series. I'm pretty much a newbie when it comes to hardware, so does anyone have an idea what could be going wrong?
i only really need it to last a couple of mins, again the power supply isnt the issue since the two lithium ions should have absolutely no problem running the Arduino and i get the same result with those.
Troubleshooting 101: Isolate your problem. Upload the basic blink sketch to your board and use your power supply of choice. If that works, as long as you're not adding additional hardware, you can be sure it's not the power supply. So then check your code. This is a very short code, so put Serial.println() after every line if necessary so you can see how far you get. Since setup() only runs once anyway, it should be easy to spot this way.
Ok so bit of progress, i followed @hallowed31's advice. First i tried hotwiring cables to the voltage regulator to make sure that it was not the fault of the pcb and got the same results.
I tried powering it through a 5v supply directly using the 5v pin and it seems to work fine, so what im suspecting now is that the nano i have with me has a defective regulator. For now i will just use an external regulator to step down the voltage to 5v (Seems like a 7805 IC should do fine?)