• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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

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:

dknguyen

Well-Known Member
Most Helpful Member
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.
 

kate90

New Member
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.

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.
 

ronsimpson

Well-Known Member
Most Helpful Member
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 ]
 

Latest threads

EE World Online Articles

Loading

 
Top