How can I write a code to make my sensor distinguish between two Leds?

Status
Not open for further replies.

kate90

New Member
hello!

I have made a circuit that consists of two IR Leds. The first Led is always ON and the second is flashing every 1 second.
how can I write an arduino code to make my infra red sensor distinguish between these two?
Can anyone tell me if there's a specific function to do so and if not what am I supposed to write?
(My sensor is connected to the Arduino and so are the two infra red Leds. the sensor basically measures distance from its position to the leds.)
 
Last edited:
First, are your LEDs actually infrared LEDs? Because if they aren't then your infrared sensor will not be able to see them.

And what you infrared sensor actually is and how it connects to your Arduino really matters here. You haven't told us so you are going to get very general answers.

If one LED is always one and the other is blinking, you can distinguish between the two by ignoring the one that is always on. This is not a coding issue unless your infrared sensor is analog and you read the values using the ADC and run some signal processing on it. I don't think an Arduino is capable of doing something like this. Or you could do it in hardware.

Either way, you would DC-block (or AC-pass) the signal. In software you would process the values coming out of the ADC in filter like an FIR filter. In hardware you would use a DC-block capacitor or a high-pass filter.
 
Hello, yes the two leds are infra red. thank you for your help.
 
My sensor is connected to the Arduino
Are you using the IR camera?
Measure the light level 10 times in one second. Make two tables. One for each LED.
The LED that is on 100% will have a peak = average.
The LED that is on 50% will have a peak = 2 x average. [ 51, 55, 49, 50, 39, 5, 2, 9, 3, 1 ]
 
Is your complete idea is to just distinguish between two IR LED? Then in that case you can use a TSOP on the receiver side. You can make both the IR LED to output different signal and then use the TSOP to distinguish between both

You can read on this TSOP and IR tutorial to know how to use them in your circuit. The tutorial actually show you how to use Arduino with TSOP buy detecting the remote button. For each remote button the IR LED on remote produces a different type of signal. What you can do is produce two type of signals on each of this LED and then use you TSOP to read these signals. Based on the signal you can tell which LED was detected by your TSOP
 
How? I'd be surprised if an Arduino were fast enough for a time-of-flight method.
Time of flight will not work with a Arduino. (not close) But I think the idea is to measure the angle between the two lights. That can be converted to distance.

There is information we do not know. Kate90 please send pictures or drawings.
 
Time of flight will not work with a Arduino. (not close) But I think the idea is to measure the angle between the two lights. That can be converted to distance.

There is information we do not know. Kate90 please send pictures or drawings.

The OP posted over a month ago and has not returned and we don't know what kind of IR sensor is being used but I was thinking about this today.

If the sensor is a simple IR transistor, I am sure that you can get distance (not necessarily very accurately) by simply looking at the analog input - pretty much what this guy has done here.

If that is what is going on, than the assignment boils down to reading the analog pin twice, 1 sec apart and take the lowest measurement (I don't know, maybe 3 measurements, .5 sec apart and take the lowest). This, to get the input when only the constant IR LED is on. Conversely, take the highest input value to get the input when both LEDs are on. That is easy enough, I guess.

What I do not understand is how the second LED can enhance the measurement. Even if the sensor is capable of discriminating the "angle" as mentioned, since the first LED is only on...you only get no 2nd LED or a mixture of the two, that is both on. Discerning an angle would seem mighty tough. I was looking at how the Sharp chip works (e.g. here) but I am not seeing the relationship to the current example.. Again, the sensor has not been identified, but it doesn't seem likely that it is very sophisticated - *drat* I wish people would not post looking for a simple line of code and then never come back

Edited to correct at least some of the text to conform to English when I am leaning too far back in my chair to read the screen.
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…