Topic: Detect USB
(Read 2274 times)
Sep 16, 2013, 03:24 am
I am designing my own board using Arduino and I had a question. The robot has both USB and LiPo inputs, and uses the MCP73831 to charge the circuit, and the TPS61200 to step up the lipo voltage to 5v. I am using the MBR0520 to automatically select the power supply, however I was wondering if there was any way to make the arduino not run the sketch it is programmed with if the USB is connected. Basically, I would like the robot to only be able to be programmed if the USB is connected, and only able to run the program if the USB is not connected and the LiPo is.
I have attached the power part of the overall circuit, please ignore 'P1', it is literally two pads that have to be soldered together. I am still in the prototyping stages of the PCB, and would like the power circuit to be separate until I know it works, so as not to damage any other components.
Any help would be greatly appreciated
downloaded 114 times
Re: Detect USB
Sep 20, 2013, 10:27 pm
I was looking for a way to tell if I was attached to the USB or running on a separate power supply, and my Googling led me to this topic. I didn't really find an answer.. only a hint or two, but I think I have a way figured out, at least for my situation.
If the Arduino is powered by USB, there is about 5V on the Vin pin, but if you power it from a higher voltage (in my case, 9 volts), there will be 9 volts on the Vin pin. I am going to try putting that Vin pin through a voltage divider (3:1 ought to do it), and feed 1/3 of the Vin voltage to an analog pin. I'll just read the analog pin and decide from that value. Might work for you .