Hi. I'm trying to detect changes on power suply. I have an Uncontinuous Power Supply and it has tree leds indicating state of charge, Green one when AC power supply is on, Yellow one when charging, and RED one when AC power supply is off.
I don't know how to connec tto arduino and grove base shield. Leds are always connected to positive born and its is +5v. Ground of each led is selected on/off by an internal UPS relay. Can somebody tell me how to connect to arduino and detect charge / led state changes ??
Thanks in advance
Connect the Arduino ground to your power supply ground.
Connect one of the Arduino digital I/O pins to the switched side of the LED.
Enable the [u]internal pull-up resistor[/u] on the I/O (input) pin.
When the LED is off, the input will read HIGH (pulled-high you the internal resistor and any leakage through the LED).
When the relay closes pulling the LED pin to ground and turning it on, the input pin will also be pulled to ground and it will read LOW.
Posting the same question to different parts of the forum is called cross-posting.
It wastes time.
Don't do it.
Thanks you DVDdoug.
I'll Try that. I suspected I need to connect both grounds, UPS an Arduino.
To Moderator:
I Apologize. I Had a trouble with firefox when tried to post it and asumed it was not written.
DVDdoug:
Connect one of the Arduino digital I/O pins to the switched side of the LED.
Enable the [u]internal pull-up resistor[/u] on the I/O (input) pin.
When the relay closes pulling the LED pin to ground and turning it on, the input pin will also be pulled to ground and it will read LOW.
Hmm, is it ?
This way you will see the LED is switched on.
You will not actually see the LED is lit, but are assuming it is because it was switched on.
You would have to find a way to see the LED has current flowing through it if you want to know the LED is on.
You can see this by connecting an analog pin to the junction of the LED and the resistor.
The resistor acts as a pull up resistor in case the LED isn't drawing current (because it's off or has died).
So in that case you would measure 5 volts.
In case the LED does draw some current, the analog pin will measure the forward voltage (probably about 1.6 volts, depends on your LED and the resistor).
It will anyways drop well below the 5 volts of your LED supply.
It depends on what you actually want to detect.
Your initial question was how to detect the LED is on.
But your description of what you want, says you want to know the LED is switched on (and AC power is supposed to be good).
So DVDdoug's solution would be OK for that, and be cheaper.
Cheaper not by means of money, but in Arduino resources.
Thanks MAS3. Yes I only need to detect led relay status,that's enough, not if led lights or not, but It's a userfull piece of information.
I have a doubt: If i declare pin(x,INPUT_PULLUP), I think i should read "1" if nothing is connected to that ping , am i right ??. I've made an attempt and receive "0". I think i have broken internal pullup resistor making bad connections...
A: Connect the pin to GND and look again, do you see a LOW ?
B: Connect a resistor to 5 volts at one side and to the pin at the other side, and repeat A.
This way you'll create an external pull up.
Re-check without the connection to GND to see a reversed result.
If A doesn't work, but B does, then you could have some defect and you might be right.