user20324: Am wondering if there is some way the Arduino can automatically power itself using through the 9v port in case the USB is disconnected, and afterwards if the USB is connected again it stop feeding from the 9v Input.

user27157: The anwser is somewhat.
If you connect a 9V battery to Vin, I'll "take over" the power wheter if the USB is connected or not. Note tought that some problems may occur when both are connected at the same time (personnal opinion). See this link for more info.
So in conclusion, if you have a USB, remove the 9V for power efficiency. Once you include the 9V though, it will take over control of the power on the ARDUINO.

user25769: there is one way you can make it.
you can use a temporary capacitor(with a voltage output near to 9v)(or a lipo battery) connected to arduino's voltage input pin and 9v battery connected to arduino with a transistor.
whatever program you are uploading to arduino, you can add a code that reads the serial port, and if serial port is not available then it opens the transistor's gate so as the capacitor gets discharged very quickly the 9v battery takes the job.when it gets the serial port again it closes the transistor's gate and arduino stops feeding upon battery and takes power from USB port.

20324: <p>Am wondering if there is some way the Arduino can automatically power itself using through the 9v port in case the USB is disconnected, and afterwards if the USB is connected again it stop feeding from the 9v Input.</p>
 27157: <p>The anwser is somewhat.</p>

<p>If you connect a 9V battery to Vin, I'll "take over" the power wheter if the USB is connected or not. Note tought that some problems may occur when both are connected at the same time (personnal opinion). See this <a href="http://www.open-electronics.org/the-power-of-arduino-this-unknown/" rel="nofollow">link</a> for more info.</p>

<p><strong>So in conclusion, if you have a USB, remove the 9V for power efficiency. Once you include the 9V though, it will take over control of the power on the ARDUINO.</strong></p>
 25769: <p>there is one way you can make it.
you can use a temporary capacitor(with a voltage output near to 9v)(or a lipo battery) connected to arduino's voltage input pin and 9v battery connected to arduino with a transistor.
whatever program you are uploading to arduino, you can add a code that reads the serial port, and if serial port is not available then it opens the transistor's gate so as the capacitor gets discharged very quickly the 9v battery takes the job.when it gets the serial port again it closes the transistor's gate and arduino stops feeding upon battery and takes power from USB port.</p>
