Simple Proximity Sensor

[Dustin Andrews] built this add-on board which works as a proximity sensor. He wanted a standalone sensor for his Arduino projects which would use a single pin as a trigger. This lets him alert the Arduino when an object approaches the sensor without the need for polling or extra code on the Arduino side of things.

As you can see, a single chip on the board takes care of all the work. That’s an ATtiny13, they’re inexpensive and sometimes you can even salvage them from consumer electronics like this color changing light bulb. The microcontroller monitors the phototransistor which is wrapped in electrical tape to isolate it from the IR LED emitters on either side. This setup creates a reflective¬†sensor. When an object nears the board, the infrared light from the emitters reflects off of it and onto the phototransistor. And since the Arduino works as an AVR programmer you don’t need special hardware to program the device.

18 thoughts on “Simple Proximity Sensor

  1. Could this not be done with a transistor and a capacitor instead of the ATTiny?

    Most IR sensors that I’ve seen are inverted, so the transistor would serve as an inverter/level shifter(If you added another pin for a second power supply), and the capacitor would filter noise out of it…

    1. Ya, I was thinking the same thing. Maybe he wanted the output to be binary. Although, I guess he could have used an op amp as a comparator and still gotten binary output from it without the ATTiny. Maybe he used the ATTiny to give you more flexibility to program in delays and adjust the sensitivity.

      1. One version did use an op-amp. This one flashes the IR LED’s off and on and compares the readings to auto-level for ambient IR. The op-amp version needed a trim pot and constant tweaking for ambient light.

    2. I imagine to tell if something is approaching or moving away you will need to store/compare at least two samples. I think this is easiest done with an 8-pin $1 uController.

      If you buy your discrete components at that shack spot, you will probably pay more for resistors/transistors/caps than you would for the ATTiny.

      1. That’s right kids, never shop at the shack. Not the best deal in town … never has been. They had their chance and blew it. Digikey is a great alternative (btw, no affiliation).

  2. I would love an explanation of the 3 pin header if someone knows the reason for it. (I.e. what pins are wired to the header, and why only these pins?).

    Other than that, awesome project. Really love the economical aspect of it!

  3. I haven’t reviwed the code, but a micro controller is usefull when u want to avoid IR interference from other sources, very difficult to achieve with a simple analog circuitry. For example it’s possible measure the light (with an analog pin) level just before the pulses and before, to make some sort of auto calibration from ambients with more ir interference

    1. I would want it to modulate the source and detect it being reflected. This should eliminate all false positive. Otherwise you could get 4 birds with a quad comparator in digital out, or go analogue with a quad opamp. In the analogue world this would be a D-beam or short range optical Theremin like positional.

      1. Synchronous detector anyone? Yet another “educational” device where the actual workings are hidden inside a microcontroller. In my opinion this operational obscurity is exactly the opposite of the transparency and imaginative application of components that HaD should be encouraging, for example building a synchronous detector around a quad op-amp or hex inverter.

        If we keep going in this direction we are going to end up with generations of electronic cripples.

    1. i would assume the light reflection and INFAred reflection would be similar aka if theres light reflected theres infared, not=not…

      of course objects cant REALLY be made invisible,

      either your brain,
      or time itself is warped,
      either of which would place INFAred in the same category as visible light

    1. If there had been an Instructable for such a thing, I wouldn’t have made this. Any chance you could make one? It might seem easy to you, but I’m a programmer, not an EE.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.