batteries or power pack

Is the arduino able to tell when it is powered by batteries as opposed to a plug pack.

I have an LED program and I want it to run permanently when powered by a plug pack, but to run intermittently when powered by batteries.

How can I do that?

thanks

tim77777:
Is the arduino able to tell when it is powered by batteries as opposed to a plug pack.

I have an LED program and I want it to run permanently when powered by a plug pack, but to run intermittently when powered by batteries.

How can I do that?

thanks

don't think so but you could code it in I should think.

Which Arduino?

How can I do that?

You can't. The Arduino has no idea where the power is coming from. It's got power, it runs. No power, no workee.

Does the voltage provided by the batteries and the power pack differ significantly ?

What is the plug pack output voltage, how is it connected to the Arduino?
What is the battery voltage, how is it connected to the Arduino?

the battery pack is 6V, the AC/DC pack is 9 volts. its an uno.

They are both connected to the 2.1mm DC socket.

This conversation is certainly dragging on !

The first thing to say is that you cannot reliably power the Uno with 6V via the DC socket because it does not give enough voltage overhead for the built in voltage regulator to work.

I've changed the regulator to 3.3 volts.

Is there anyway to determine if the Uno is running on batteries or AC/DC power?

What about something like running a power line to an A/D and checking for ripple?

tim77777:
I've changed the regulator to 3.3 volts.

Have you changed the UNO to work at 8Mhz ?

It may not be reliable running at 16Mhz and 3.3V.

Depending on the version and the board, there is circuitry on some that will favour the jack over the USB power. For this to happen, Vin has to be significantly higher (sort of) than the 5V you get from the USB. Typically the value is 6.6V but the tolerances of the components that go into these boards could drive that up as high as 9.

The input is fed into an op-amp wired as a comparator and if all is great, will trigger a transistor to switch off the supply for the USB. All other USB functions remain active though.