Arduino Power Supplies differentiate

Hello,

I am using Arduino Mega 2560, and I know that I can powered the arduino through the power jack or Vin ( or USB). Now my questions are:

  • Is there any function in arduino that can tell me if the board is powered via the power jack or Vin pin??
  • Can I powered the board through power jack and Vin pin in the same time? I want to use the Vin pin by default and the Battery connected via power jack as backup.

Thanks in advance...

  • Is there any function in arduino that can tell me if the board is powered via the power jack or Vin pin??

No.

  • Can I powered the board through power jack and Vin pin in the same time?

Yes.

  • Can I powered the board through power jack and Vin pin in the same time? I want to use the Vin pin by default and the Battery connected via power jack as backup.

That is how the board works, defaults to Vin if both voltage sources are available.

I have a LED that must be ON when the board powered through power jack and OFF when powered from Vin pin. Doyou have any solutions for this task?

And another Q: when the power cut off from the Vin pin then the power will come from the power jack. Does the board reset while doing this??

Thanks for your fast respond...

And another Q: when the power cut off from the Vin pin then the power will come from the power jack. Does the board reset while doing this??

What happens when you try ?

I have a LED that must be ON when the board powered through power jack and OFF when powered from Vin pin. Doyou have any solutions for this task?

Connect the LED between the power jack and the voltage regulator.

Mahmood:
I have a LED that must be ON when the board powered through power jack and OFF when powered from Vin pin. Doyou have any solutions for this task?
One solution might be to wire a two resistor divider from Vin to ground and read the reduced junction voltage wired to an analog input pin.Your sketch could then read the voltage and make a digital output to an led/resistor.
And another Q: when the power cut off from the Vin pin then the power will come from the power jack. Does the board reset while doing this??
No reset.

Thanks for your fast respond...

Depending on how detailed you want to get you could run a divider bridge from the barrel jack and monitor voltage from an analogue pin, that would tell you if the barrel jack was powered, although not directly which input was in use. For that you'd need to monitor both inputs voltages over 2 pins.