2 Replies Latest reply on Jul 15, 2019 8:57 PM by fmilburn

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

    kate90

       

      • 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.)

       

       

        • Re: How can I write a code to make my sensor distinguish between two Leds?
          fmilburn

          Hi Kate,

           

          The IR distance sensor works by reflecting IR light off of a surface.  If the LED that is constantly on has the right wavelength and is pointing at the distance sensor, then it might detect it as a close-by object.  It might show the blinking LED as one that changes from close to far away.  So try pointing the distance sensor at the LEDs and see how they influence the reported distance.  But that might not make for a very good detection technique due to problems with wavelength, modulated signal, all sorts of things.

           

          What might work better is to use a phototransistor but it really should match the wavelength of the IR LEDs being used.  These IR Breakbeam sensors sold by Adafruit may be using that technique.  They also list Arduino code.  When the output of the phototransistor stays above a certain level constantly when pointed at a LED (you will have to determine this by experimentation) then it is pointed at the one that is constantly on.  If it fluctuates up and down then it is pointed at the one that is blinking.

           

          Not to complicate this even further, but you don't want "infrared receivers" like the TSOP38238 used for television remotes and the like because they work on a modulated signal.

          2 of 2 people found this helpful
          • Re: How can I write a code to make my sensor distinguish between two Leds?
            fmilburn

            Also, how far distant is the sensor from the LEDs?

            2 of 2 people found this helpful