To power my Arduino Nano, I used 6 AA batteries liked to GND and VIN. My question is: If I also add a 12v power supply to these pins, can I use it sometimes plugged in, and sometimes on batteries, or will it damage the batteries? Since are not rechargable. Is it better to use the USB mini port for wired power supply to not damage the batteries? Thank you.
Feed the power supply to a series diode then to Vin.
Put a series diode on the battery and feed into the Vin pin.
A series diode, you mean something like this?: https://m.littelfuse.com/~/media/electronics/datasheets/power_semiconductors/littelfuse_power_semiconductor_schottky_diode_dstd5200_datasheet.pdf.pdf
As in this drawing.
1N400X diodes should be sufficient.
BTW 12V to the Vin pin is over kill, 9v is better.
Thank you Larry but I'm a very beginer to these things, Isn't there an easier method? If the battery switch is OFF (GND wire is cut) there would still damage the batteries if I connect a 12v power supply to GND and VIN pins?
If you follow the circuit wiring above you will have no problem.
This shows the physical orientation of the 1N400X diode; you need 2 of these diodes. Costs about 20 cents.
No switch will be needed.
6 X 1.5v = 9v battery voltage.
Since 12v is larger than 9v, when the power supply is plugged in to AC, power at the Vin pin is automatically selected to come from the power supply, not the battery.
You can of course connect the two power supplies to a SPDT switch then to the Vin pin.
Can I just connect the diode to the 12v power supply? or it needs to be connected also on the battery wires? Because the connection with the battery is more difficult for me to access since I used some hotglue. I found 1N4007 diode in my kit. Is it good?
No. The battery diode keeps the 12 supply from trying to charge the 9V battery up to 12V (and almost certainly damaging the battery).
And what if I use the USB port to charge the Arduino, will still damage the battery? Of if I use 9v power supply. Is 1N4007 good? I found some in my kit.
I don't think so. The USB power is on the other side of the 5V (or 3.3V) regulator. I don't think USB voltage will go back through the regulator, and if it does the 5V from USB can't over-charge your 9V battery.
Ok, Thank you John!