Pages: [1]   Go Down
Author Topic: led output as an input  (Read 797 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Sr. Member
****
Karma: 0
Posts: 376
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi

i need to take what is the output for a led on a comemrcially purchased board, disconnect the led and feed that into an arduino pin, so that i can put a state indicator on an LCD and thus monitor the state of varios boards at the same time through the LCD.
no output on either board will go over 5v

my question is two fold,
1  can i use digital read to get the state of each input. and then use an if statement show the indicator based on the digital input being over 50 for example,

2, what should i do to protect the arduino input pins against over voltage?

thanks in advance for any help
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26497
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Why remove the LED at all?
Simply make up a simple optocoupler, then you don't need to worry about over-voltage protection.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 547
Posts: 27363
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Not quite making sense to me here.

If "no output on either board will go over 5v" then how can "digital input being over 50 " occur?
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 640
Posts: 50335
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
If "no output on either board will go over 5v" then how can "digital input being over 50 " occur?
I think that should have been "analogRead() value being over 50".
Logged

Ayer, Massachusetts, USA
Offline Offline
Edison Member
*
Karma: 54
Posts: 1857
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

hi

i need to take what is the output for a led on a comemrcially purchased board, disconnect the led and feed that into an arduino pin, so that i can put a state indicator on an LCD and thus monitor the state of varios boards at the same time through the LCD.
no output on either board will go over 5v

Unless you share a common power source between the Arduino and the commercial board, I doubt this would work, since the current would need to flow in both boards.

As AWOL suggested what you want is called an opto-coupler or opto-isolator.  One way is to take the LED out of the board and connect the LED power and ground to an opto-coupler on one side, and the Arduino pin and ground on the other.  Here is a tutorial: http://arduino-info.wikispaces.com/Popular-ICs.

The other way is to make your own opto-isolator as AWOL suggests.  An opto-isolator basically has a LED inside of the chip, and a light sensor.  Since you have a light already, you would just need to attach a photo sensor to the led, and then cover it up with tape so the only light that the photo sensor sees is the LED.

Quote
my question is two fold,
1  can i use digital read to get the state of each input. and then use an if statement show the indicator based on the digital input being over 50 for example,

A digital input only returns 0 or 1.  It does not return a voltage like 50.  You could use an analog input if you needed that.

With digital inputs, you need to decide whether to add a resistor to your circuit for the normal pull down inputs, or switch to use pull up switches (which flips the sense of the digital input, it would return 1 if there is no connection).

It occurs to me that you may need to sample the light several times, since the commercial board may be turning it on/off quickly to get a desired brightness.

Quote
2, what should i do to protect the arduino input pins against over voltage?
Opto-isolator.
« Last Edit: August 09, 2012, 09:25:11 am by MichaelMeissner » Logged

Offline Offline
Sr. Member
****
Karma: 0
Posts: 376
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
If "no output on either board will go over 5v" then how can "digital input being over 50 " occur?
I think that should have been "analogRead() value being over 50".

Thanks for that,
Logged

Offline Offline
Sr. Member
****
Karma: 0
Posts: 376
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset



"Unless you share a common power source between the Arduino and the commercial board, I doubt this would work, since the current would need to flow in both boards."

I was planning to conenct the grounds of each seperate board to the arduino ground,
is that a bad plan ?


Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 547
Posts: 27363
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, only the grounds need to be connected. "Common power source" implies both (all?) boards use the same 5V source, that is not needed.
The analog reading of 50, that's ~.24V, is that what you see with a meter? Seems pretty low for an LED, I would have expected more like 1.7 to 2V from one side of the LED to the other.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Sr. Member
****
Karma: 0
Posts: 376
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I was just using the 50 as a rough example,
i dont need to really know what level the Analogue read is, I just need to know that the voltage is above the OFF voltage, and 50 seemed to be a reasonable margin of error for if there is a little voltage present when the LED should be off,

i was going to use an
if (led>50)
lcd.print ("led on")

that kind of thing ,
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 547
Posts: 27363
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok. Maybe put a meter on & confirm.
May get different reading if LED cathode goes to Gnd, vs cathode going to a resistor to Gnd for example.
Or if the cathode was switched hi/lo vs the anode being switched hi/lo.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Vilvoorde Belgium
Offline Offline
Newbie
*
Karma: 1
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

On the board with the leds that you want to monitor, connect your voltmeter to the ground and measure with the other lead of your voltmeter the voltage over the led when the led is on and of.
Assuming you will see a really low voltage when the led is off and a well over 2V voltaged when the led is on...
Connect the ground of the Arduino to the ground of the "to be monitored" board.
Set your input pin to input (default at stratup)
Use digital read ... chances are really high it will work.
If it would not work chances are high that the Arduino will always read a high (even when the led is off). If that is the case... connect a 10k resistor between the input pin and the ground on the Arduino (it shoud make it so that you read a lowwhan the led is off).

Jan Huygh
Logged

Pages: [1]   Go Up
Jump to: