Okay, technically, you won't trip if you build this. You won't even get to trip other people. The image is misleading, but it got your attention, right?

I needed an IR tripwire for an upcoming Halloween project. I looked and looked, but I couldn't find anything that didn't involve a laser, which wouldn't work for my needs, because lasers are visible when there's lots of fog, and what would Halloween be without LOTS of fog?? There is information on using parts of an air freshener for a passive infrared detector, but that would involve spending money, and I've got a bin full of parts waiting to be used...

Thus, I decided to build my own. It's going to trigger a microcontroller, so a high or low trigger voltage would work fine for my purposes. I tried a few different things, and finally came up with one that worked well.

Image courtesy of OpenClipArt.org. Licenced in the public domain. Thanks to the creators for allowing free use of their materials without attribution (although I like to give it anyway).

Step 1: Parts

I got all the pieces I needed for this from my collection of parts that I have on-hand.


2 general purpose NPN transistors 2222

I used PN2222s, but you can choose different ones based on your needs. Microcontrollers don't need a lot of current at their inputs, so these should be overkill for this project. Salvaged will work fine as well (but I was too lazy to look up the pinouts of my salvaged NPNs, so I used the ones I know).

1 IR Diode

I bought a bunch of these a few years ago from an electronics shop. I have no idea what the part number is, but any two-lead IR diode should work. Heck, you can use an IR transistor if you like, but I had the best results with my diode.


I haven't even pulled this out of the mostly-busted remote control that I'm going to salvage for the project. If you've got an unused or half-working remote control, that will give you an easy way to test the functionality of the sensor (because you'll be able to see the oscillations of the IR LEDs in the receiver, and avoid detecting atmospheric IR interference).

1 Visible LED

You'll probably want this to see if your circuit is working. Anything you've got that'll be visible when the system is working.

A few resistors

I just grabbed some at random from my box. You're going to need a current limiter sized for your visible LED (I think I used a 100 Ohm). This will depend on your power supply, your LED, and your eyesight. I used a small, dim LED just as a quick indicator that won't tip off anyone who's not looking for it.
I also needed a couple of pull-up and -down resistors. I think I used something like 100Ks. Really, anything high enough should work. It's a good idea to have a variety on hand, to try and see how they effect the characteristics of your circuit.

A power supply

Anything with a voltage lower than what your transistors are rated. I'm using a 5V power supply, as the circuit will be running alongside a microcontroller that also runs off 5V. Use whatever the final power supply will be, so you can tune it to your needs.

Some Perf board and/or a breadboard

I tried out my circuit on a bread board, then soldered it all together on a small piece of perf board.

Other stuff you'll probably need

A short length of 1" diameter pipe.

This is used to filter extraneous IR from affecting your sensor. It's optional, but I wanted my circuit to operate in full daylight or the dark of night (actually, both!), and this really improved results.

Electrical tape

You know what that is, right? Any old colour will do.


Yup. Lots is better than not enough.

Electronics tools 

Pliers, utility knife, etc. All that fun stuff.

A digital camera

Did you know that you can test the operation of an IR led by looking at it though a digital camera? It's a really handy way to check the batteries in your remote if you suspect they may be faulty. Just point the remote at the camera, press a button, and watch the camera's screen. If it lights up, you're golden. Does not work with a film camera, and even if it did, the results might prove to be slow...

Again, image is from OpenClipArt.org. Sweet, no?

Step 2: How It Works

The circuit is a simple darlington pair of transistors (in this case, NPNs), with a reverse-biased IR diode as input. The output is high when there is no exposure to IR light, and low when there is.

When IR light hits the photodiode, it allows a small amount of current to flow between the base of Q1 and VCC. This flow of current is amplified through the darlington pair, allowing a high amount of current to flow from the output. The current required by a microcontroller for input is much, much, much less than the transistors are capable of delivering, so no need to worry about burning out your transistors.

This worked out well for me, because most of the time, there will be exposure to IR light. That's because there will be IR light shining from IR leds onto the detector. Once the beam of light is broken, the sensor output will go high, triggering an action.

If you desire the opposite, might I suggest using PNP transistors in a similar setup.

Image of darlington pair courtesy of Wikimedia commons, author Michael9422. Thanks to the author for the CCA share-alike licence!

Step 3: Breadboard Your Circuit

Lay out your parts on the breadboard.

The circuit is a simple darlington pair with the IR diode functioning as the input, and an indicator LED tied between the output and VCC. This arrangement gave me the cleanest on/off results compared to others that I tried. Better still would be to use a 555 as a comparator to really give you a nice, square wave.

Check the image notes for information about where the IR diode and visible LED are connected.

Geez, that idea is so good, I might just use it! Hah!

To test the circuit:

Point any IR remote at the IR diode, and press a button. You should see the LED flash. If it's already lit, turn off some of your overhead lights (especially the incandescent bulbs). You should be able to see a visible pulsing to the LED, indicating that it's picking up what you're laying down.

Move the remote around to check out directionality, distance, and sensitivity of your circuit.

Step 4: Make It Permanent

Leave your circuit on the breadboard, and build a duplicate on some perf board. It's nice to have such a low part-count, so you don't have to worry about running out.

At least, that's how I did it. You're free to do whatever works best for you. Stick the pieces on the board, hook 'em up, and let 'er rip. Since I only had one IR diode left that I have yet to burn out, I left that on for last, and put it on once all the other pieces were attached.

Notice that I put the IR diode on facing backwards, then bent it around to look outwards. It proved easiest to arrange the parts like this and still make the clean connections I wanted on the underside of the board. It also leaves me some wiggle room to point the IR diode where I want it.

As a final detail, I used an RJ11 connector to allow easy connection and communication. Maybe in the future I can set it up to go wireless, but that might be beyond my meager abilities...

Step 5: Stick It in a Pipe

By using a short length of pipe, you can make the circuit more directional. Use a long enough segment to ensure that the IR diode is in the shadow.

I used 3/4" PVC, with a PVC coupler on the end to clean up the appearance and hide the RJ11 connector (that's telephone cable, if you're not a super geek) that I used.

This is completely optional. Arrange yourself how you like.

Step 6: Make the IR Emitter

You'll need to make something that constantly emits IR light. You'll also need to be able to point the light into the end of the pipe you used in the previous step.

I had a battery box sitting there, looking lonely. I wired it up to my IR LEDs with a current-limiting resistor. Turn it on, point it, and you're all set.

Step 7: Connect It to Your Microcontroller, Code It Up, and You're All Set!

For this project, I used an MS430 launchpad. It's really, really, really, really cheap. I'm talking cheap. $4.30 cheap, shipped from TI. I used the MSP430G2553 20 pin DIP, because I happened to have a few 20 pin DIP sockets laying around, and I'll use them on my proto board. Any of the smaller ones would work fine, and I'm sure I'm wasting quite a bit of real estate using an overpowered chip to do something so basic. Like I said earlier, a 555 timer would probably be more than powerful enough.

It's not the easiest platform to learn. My coding skills are really basic, really rusty, and weren't too thorough to begin with. Thus, the lousy, bulky, inefficient code.

Anyone who's good with C can probably point out so many things wrong with how I wrote the code that they'd take longer to describe what's wrong that it took to write the code in the first place. Basically, I hacked up code from the MSP430 tutorials to run a continuous check of the input, and when the value changes more than a set amount (approximately 10% different), it will run a routine.

The main thing that I wanted to ensure was that as the sun goes down, the tripwire will continue to work properly. So I set up the code to check and set a threshold every once in a while (a few times a minute). This means that as the ambient light level changes, the sensor will automatically recalibrate to compensate for the change.

All the coding was done in Code Composer Studio 5, which is free up to a certain program size. The neat thing is that the size of the memory on the MSP430s is smaller than the limit, making the development environment effectively free.

*Author's Note: Because I had so much trouble with the code for this project, I ultimately gave up on the big idea this was to be used with. I kept the module, and an Arduino is on its way to my house. I may use it for some other purpose some time in the future. *
<p>Hey really nice project could you help me out with exact values for resistances? Kindof a noob here just looking to get this done for a larger idea </p><p>Thanks</p>
Great build and explanation! I've been looking for a project to do with my son, and this one looks to be ideal. Thank you!

About This Instructable



Bio: Teacher in Canada. Complete techno-junkie. Open-sorcerer. Scriptographer. I am devoted to learning - teaching just sort of follows...
More by jptrsn:Haunted Portrait for less than $20 Insulated Sleeping Pad (thermarest) Enterprise-Grade Network on a Budget 
Add instructable to: