krayzielilsmoki
Posts: 18
Joined: Tue Sep 09, 2014 2:02 pm

How to read a bi-color LED

Thu Sep 11, 2014 1:06 pm

I would like to be able to have the raspberry pi recognize when an LED is on.
This is a bi-color led that has 2 legs and uses reverse polarity to change colors.
These are the readings I got from it when it was lit up
Green: -1.87v
Orange: 1.84v

What GPIO pins should I use for this and what code would I need to have it recognize when one of the colors is on?
I would like to use this as part of the logic for a bigger project.

Thanks for the help!

User avatar
0xFF
Posts: 202
Joined: Tue Nov 20, 2012 7:52 pm
Location: Poland

Re: How to read a bi-color LED

Thu Sep 11, 2014 1:23 pm

You can use RGB light sensor, like this:
http://bradsrpi.blogspot.com/2013/05/tc ... ry-pi.html

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: Korea

Re: How to read a bi-color LED

Thu Sep 11, 2014 1:39 pm

A bi-colour LED with two legs usually has a red LED and green LED wired up in reverse parallel. To get red, send current one way. To get green, send current the other way. To get orange, use ac.

Do you have an oscilloscope? Try looking for ac when the LED is orange. Or try flicking your eye past the LED and see if you notice red and green flickering.

User avatar
redhawk
Posts: 3465
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1

Re: How to read a bi-color LED

Thu Sep 11, 2014 1:41 pm

Where is the LED going to be used??

Detecting the flow of current would provide difficult on the Pi since the GPIO can only measure 0v to 3.3v it cannot measure negative voltages.
A solution would be to use 2 opto-couplers in parallel but have one with it's anode and cathode swapped to detect current going in the opposite direction.
Interfacing the Pi would then only require 2 GPIO input pins with 2 pull-up resistors from the 3.3v supply rail.
An alternative method would be to use a RGB light sensor as suggested by the previous poster but that would require an enclosed fixture to ensure no external light could penetrate and interfere with the light sensor.

Richard S.

krayzielilsmoki
Posts: 18
Joined: Tue Sep 09, 2014 2:02 pm

Re: How to read a bi-color LED

Thu Sep 11, 2014 1:42 pm

0xFF wrote:You can use RGB light sensor, like this:
http://bradsrpi.blogspot.com/2013/05/tc ... ry-pi.html
Looks like this is an extra device that I would put over the bi-color led and have it tell me what color it sees. This is an interesting option that might work. Is there any way of doing it without extra accessories? I hoping for a simple way to just read if the voltage is positive or not and go from there.

krayzielilsmoki
Posts: 18
Joined: Tue Sep 09, 2014 2:02 pm

Re: How to read a bi-color LED

Thu Sep 11, 2014 1:45 pm

redhawk wrote:Where is the LED going to be used??

Detecting the flow of current would provide difficult on the Pi since the GPIO can only measure 0v to 3.3v it cannot measure negative voltages.
A solution would be to use 2 opto-couplers in parallel but have one with it's anode and cathode swapped to detect current going in the opposite direction.
Interfacing the Pi would then only require 2 GPIO input pins with 2 pull-up resistors from the 3.3v supply rail.
An alternative method would be to use a RGB light sensor as suggested by the previous poster but that would require an enclosed fixture to ensure no external light could penetrate and interfere with the light sensor.

Richard S.
I am just trying to have the raspi recognize if my tv is on or not. I figured the best way to do it is by wiring to the led that indicates if the TV is on or off. I wouldn't need the pi to recognize the negative value, just the positive. So if I can get it to recognize when the value is at the 1.84v that would be perfect because that would tell me the state of the tv.

User avatar
redhawk
Posts: 3465
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1

Re: How to read a bi-color LED

Thu Sep 11, 2014 1:52 pm

There are other ways to detect the presence of the TV I'm not sure if the LED would be a good method considering the need to enclose the light sensor.

Does your TV have any USB or Scart connectors at the back??

Does it use the old (AM radio killer) CRT technology??

Richard S.
Last edited by redhawk on Thu Sep 11, 2014 1:56 pm, edited 1 time in total.

krayzielilsmoki
Posts: 18
Joined: Tue Sep 09, 2014 2:02 pm

Re: How to read a bi-color LED

Thu Sep 11, 2014 1:55 pm

redhawk wrote:There are other ways to detect the presence of the TV I'm not sure if the LED would be a good method considering the need to enclose the light sensor.

Does your TV have any USB or Scart connector at the back??

Does it use the old (AM radio killer) CRT technology??

Richard S.
This is a newish flatscreen tv. I was looking for a low power output that will tell me when the tv is on. I figured if it sends power to the led then I can use that as my source of power to tell me that its on. Its not really the LED that I am looking at, rather the voltages that it is outputting to that location during the on/off state.
So essentially I want the raspi to recognize when the voltage is at 1.84

krayzielilsmoki
Posts: 18
Joined: Tue Sep 09, 2014 2:02 pm

Re: How to read a bi-color LED

Thu Sep 11, 2014 2:11 pm

This LED situation may be too complex for what I need.
Here is a different scenario

If I can find another source of low voltage output while the tv is on, that will give me 0v when off, and a low voltage when on... how do I get the raspi to recognize that?

User avatar
PeterO
Posts: 4944
Joined: Sun Jul 22, 2012 4:14 pm

Re: How to read a bi-color LED

Thu Sep 11, 2014 2:41 pm

krayzielilsmoki wrote:This LED situation may be too complex for what I need.
Here is a different scenario

If I can find another source of low voltage output while the tv is on, that will give me 0v when off, and a low voltage when on... how do I get the raspi to recognize that?
Use an opto isolator, then you can safely sense the presence of higher voltage supplies in the TV.

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

Return to “Beginners”