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.

Comments

  1. Rogan Dawes says:

    Some heatshrink tubing might be a better idea than the electrical tape. You can always shrink the portion around the phototransistor’s legs to keep it in place.

  2. plfx says:

    The way the cap is straddled across the attiny is adorable.

  3. izzy84075 says:

    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…

    • Don says:

      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.

      • dustinandrews says:

        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.

    • M4CGYV3R says:

      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.

      • Keith says:

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

  4. hospadar says:

    Or use a 555 if you just want to trigger when something enters/exits the range, also could add a little debouncing.

  5. zerocool42 says:

    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!

  6. wetomelo says:

    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

    • echodelta says:

      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.

      • AussieTech says:

        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.

  7. Vonskippy says:

    Reflected IR, will that detect Vampires?

    • NewCommentor1283 says:

      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

  8. Haku says:

    How well does this sort of setup stack against one which uses a 38khz IR sensor (which should work better in bright light) like this one: http://www.ebay.co.uk/itm/140741450272

  9. ftorama says:

    an oscillator driving leds, an IR remote receiver such as a TSOP1138 and it’s done….and no need for a microcontroller for such a small thing

    • dustinandrews says:

      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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 96,742 other followers