Kids' Basics: Door Alarm

Using Infrared Light

Daniel Koch

Issue 39, October 2020

Does someone keep eating your chocolate, taking your stuff, or just being an annoying sibling and moving things in your room? Build a doorway alarm to tell you as soon as someone goes through the door!


Our project is far from undefeatable but does the job as well as anything within Kids’ Basics simplicity criteria can do. To make this handy little alarm, we’re going to explore yet another way to use the 555 timer integrated circuit (IC). We’re also using an infrared sensor and light. Infrared (IR) is a band of light that is not visible to the human eye.

The only assumed knowledge is that you can read the article, and have basic component identification skills. Even then, you’ll probably be able to follow the instructions without knowing which components are which, but it would help a lot.

The Build:

Besides the electronic parts, you will need some basic hand tools for this project. A small pair of pliers and some flush-cut side cutters are always handy. It would be good to have wire strippers but if these are not around, then you can carefully use side cutters. Some tape to insulate wire connections is needed. It can be masking tape or cello (clear sticky) tape if you don’t have any proper PVC electrical tape, but never use these on anything other than Kids’ Basics projects where the voltages and currents are small. Scissors and glue for paper, along with some Blu Tack® or similar round out the list.

Parts Required:JaycarAltronicsCore Electronics
1 x Solderless BreadboardPB8820P1002CE05102
1 x Pack of Breadboard Wire LinksPB8850P1014ACE05631
4 x Plug-to-Socket Jumper WiresWC6028P1022PRT-12795
2 x 470Ω Resistor *RR0564R7550COM-05092
1 x 10kΩ Resistor *RR0596R7582COM-05092
1 x 270kΩ ResistorRR0630R7616COM-05092
1 x 18nF MKT or Ceramic Capacitor *RM7080R3016A-
1 x 22μF Electrolytic Capacitor *RE6079R5084CE05130
1 x NE555 Timer IC %ZL3555Z2755002-512-LM555CN
1 x IR LEDZD1945Z0880AADA387
1 x LEDZD0120Z0701CE05103
1 x PhototransistorZD1950Z1613-
1 x Piezo BuzzerAB3462S6109ADA1536^
1 x 9V Battery SnapPH9232P0455CE05205
1 x 9V BatterySB2423S4970BCE05337

Parts Required:

* Quantity required, may only be sold in packs. % Any 555 will work. Some are NE555, some LM555, and others exist as well.

^ This is a breadboard version, not flylead, and will need extra wire links to use.

Step 1:

Position the breadboard in front of you with the outer red (+) rail away from you and the outer blue (-) rail closest to you. Insert the 555 timer so the notch or dot showing pin 1 is to the left. Also insert the two wire links that join the two sets of power rails together, blue (-) to blue (-) and red (+) to red (+).

Step 2:

Insert the three wire links and two resistors at the top of the board. Note that one wire link is uninsulated and hard to see between pins 6 and 7. The 270kΩ resistor (red-purple-black-orange- -brown) goes from the red (+) rail to pin 7, while the 470Ω resistor (yellow-purple-black-black- -brown) goes from the red (+) rail to an empty spot on the left.

Step 3:

Insert the wire links and resistors below the IC. The 10kΩ resistor (brown-black-black-red- -brown) goes from the blue (-) rail to pin 2, while the 470Ω (yellow-purple-black-black- -brown) goes from next to the wire link from pin 3, to meet the wire link at the right from the blue (-) rail.

Step 4:

Install the two capacitors at the top. The 18nF MKT goes from pin 5 to the blue (-) rail. The Electrolytic 22µF goes from pin 6 to the wire link to the blue (-) rail beside the MKT, with its negative stripe to the wire link. Note that you can use any 18nF capacitor, we just find MKTs easy to source and work with.

Step 5:

Install the LED and buzzer below the 555. The LED goes between the wire link and resistor, with its short leg to the resistor. The buzzer has its red (+) wire in the same row as the wire link and its black (-) wire to the blue (-) rail.

Step 6:

Take the phototransistor and IR LED, and bend the ends of their legs like this with small pliers. This helps them stay into the sockets on the jumper wires we’re using. Without this step, they tend to slide out too easily, and don’t make very reliable electrical contact.

Step 7:

Cut two plug-to-socket jumper wires, one light and one dark, in half and bare the wires on both sides of the cut. You can use side cutters to strip the wires. However, be very careful to apply enough pressure to cut the insulation but not enough to cut the wire. Wire strippers are better.

Step 8:

Strip the ends of a piece of twin-core wire long enough to go around your door frame. Twist the ends into the ends of your jumper wires, making sure each colour connects to the ends of the same wire. Tape over the joins.

Step 9:

Push the ends of the IR LED into the sockets of the jumper wires. Take care that the long leg goes to the light colour and the short leg goes to the dark colour. Tape over the exposed legs, and press in the middle to keep them separated. We have used clear tape here for photographic reasons but it is not the best choice electrically.

Step 10:

Plug the other end of the IR LED wires into the breadboard. The light coloured wire goes to the end of the 470Ω resistor (yellow-purple-black-black- -brown) off to the top left of the 555, while the dark coloured wire goes to either the upper or lower blue (-) rail.

Step 11:

Insert the phototransistor into a pair of plug-to-socket jumper wires. Again choose a light and dark colour here. This time, the short leg with the flat side on the case rim goes to the light colour, while the long leg goes to the dark colour. Tape the exposed metal and pinch in the middle to keep separation.

Step 12:

Connect the light coloured jumper wire from the phototransistor into the lower red (+) rail and the dark wire into the row to meet pin 2 of the IC. Connect the battery snap wires, the red one to the upper red (+) rail and the black one to the lower blue (-) rail. Although the rails are connected, doing this keeps the wires apart if one comes loose.


Plug in a battery and see what happens. If you don’t hear a noise straight away, cover the phototransistor with your hand. If you still don’t hear a noise, check all of the connections, starting with the phototransistor. Make sure it is firmly in its sockets, and the other ends are placed properly. Now check the buzzer, as the connections come loose easily from the breadboard. Failing this, start checking connections against the photos from step 1.

The challenge with this circuit is that the phototransistor is sensitive to visible light as well as IR light. There are plenty around which only sense IR, but they are not available over the counter at easily accessible retailers. They are from the trade and online suppliers not geared up to dealing with the general public. To get around this, we need to shield the sensor from ambient light (the light coming from windows and room lights). While we’re at it, we will narrow the beam sent from the IR LED, too.

To do this, cut two squares of black or dark coloured paper, around 5cm by 5cm. Cover one side of each with stick glue, and roll one around the phototransistor and the other around the IR LED. Be careful to keep the roll straight, and if anything, let it open slightly into a cone rather than letting the inside get smaller and block the light.

Alternatively, look for an existing tube to use as a basis. Some drinking straws are a good size, as are some empty barrels from ballpoint pens. You may still have to cover or colour this tube to stop light getting in. You could use black or dark paper, or you could colour it with a permanent marker or paint.

Now with your phototransistor and IR LED shielded, all that remains is to use Blu Tack® or similar to mount the phototransistor on one side of your door frame with the breadboard and battery beside it, tac the wire neatly over the frame, and mount the IR LED on the other side. Make sure the two tubes are pointing at each other. You may wish to use the LED on the board for this and disconnect the buzzer while you experiment to find alignment. Ours is much shorter for photographic reasons but make sure you go over the door frame and not across the floor, unless you are able to hide your cable under a mat or the like. Otherwise, it presents a trip hazard.

If you’re struggling to align the tubes, ask to borrow a mobile phone from an adult. The cameras on most phones can see the IR light, so you can use the camera’s viewfinder mode (its normal state while you’re looking at the screen and can see what the camera sees before you press the button) to see the IR light. Hold the camera near the phototransistor’s tube, and have someone else move the IR LED tube until you see the light getting close to the camera. From there, you should be able to finish the alignment by watching the LED on the breadboard.

This whole process is easier if the tubes are hand-made and slightly cone-shaped, as they will not have to point at each other so perfectly. If you're still having trouble, try trimming back the tubes a little at a time. We recommend starting with the IR LED, as it doesn't matter if this gets short enough to spill light, but if the phototransistor's tube gets too short, it will let stray light in and false-trigger.

How it Works:

The key to this circuit is the trigger pin, Pin 2, of the 555 IC, and the components connected to it. Pin 2 triggers the IC when the voltage at it falls below half of whatever is at the control pin, pin 5. Pin 5 is often connected to ground by a capacitor in the circuits we have built in Kids’ Basics, and when that is the case, the voltage at that pin is one third of the supply voltage. This means that to trigger the IC by pin 2, we need to drop the voltage there to nearly nothing.

We do this with the phototransistor and resistor connected to pin 2. Looking at the schematic, if you are comfortable reading them, you can see that the current flows from the positive supply rail into the transistor. To recap, transistors are an arrangement of materials in a sandwich where a small amount of current fed to the middle of the sandwich allows much more current to flow from one of the sides to the other. They are always polarised, so the current can only flow into one of the sides and out the other.

The curious thing is, this transistor has no middle leg, and is packaged in a clear plastic case that looks like an LED. It even has the rim and flat side! That's because in most transistors, the middle of the sandwich (called the base) is sensitive to light as well current, which is why they are always in black plastic packages. With careful selection of materials and construction, they can be sensitive enough that light is able to control the current flow across the transistor. The more light, the more current flows. That’s why they are called phototransistors. The connections work differently to LEDs, and the one we used has the flat side and short leg connected to the positive power rail.

When enough light is falling on the phototransistor and enough current flows, the voltage at pin 2 is above the minimum needed to keep the output of the 555, pin 3, ‘low’ or off. However, pin 2 does not draw much current on its own, almost nothing in fact. Because of that, there is no current flowing through the phototransistor to cause the voltage to rise. To cause current to flow in the phototransistor, we need to give it a load. For this, we used a 10kΩ resistor. This is low enough to draw enough current through the phototransistor but not low enough that there is not enough voltage appearing at pin 2. Try the circuit without this 10kΩ resistor and see what happens (or doesn’t). During development, we tried a 1kΩ resistor, and had to hold the IR LED almost on top of the phototransistor to turn the buzzer off.

Now that covers what happens when light is falling on the phototransistor. What happens when the light is interrupted? The phototransistor stops conducting current, and the voltage at pin 2 disappears. This causes a device inside the 555, known as a ‘flip flop’ to change its state. There is a lot more going on than this, but the net effect is that the output goes ‘high’ or on. At the same time, there is an internal transistor connected between pin 7 and ground, which now turns off. Previously, the 22μF C1 capacitor connected here was short-circuited by this conducting transistor, but now it can start charging up via the 270kΩ resistor R4. These two components control the time that the pin 3 output is high. When the voltage at the capacitor, sensed by pin 6, has reached two thirds of the supply voltage, the internal flip flop is reset, the output goes low, and the discharge transistor inside the 555 turns on, draining the capacitor to ground.

This all means that even if the light beam is only broken for a short time, the output will still last an amount of time controlled by the 22μF capacitor C1 and 270kΩ resistor R4. Changing these values changes the ‘on’ time of the buzzer. We have it set up for around six seconds.


Changing R4 and C1 will change the on time of the buzzer. Increasing either or both makes it longer, while decreasing them shortens it. There is a formula for this. We could explain the maths but really, for Kids’ Basics, it’s better to just experiment.

The alarm is by no means foolproof. At some point, your annoying brother or sister will probably figure out how to crawl under or step over the beam, or reach around the door frame and disconnect the battery or buzzer. You can reduce this by mounting the circuit in a cardboard box with a hole for the buzzer. Use double-sided tape to mount the buzzer at the hole.

If you’re feeling adventurous, you could mount the phototransistor at the bottom and the IR LED at the top of the same side of the door frame, then Blu Tack® on a series of mirrors to bounce the beam across, down, across, down, and so on until it reaches the sensor. The problem with this is that each reflection loses some light, and aligning the mirrors perfectly will be hard. You may need a stronger source of light such as a laser pointer but it is worth a try if you feel so inclined.

If you built the Book Safe project from Kids' Basics in Issue 24, you may remember the way we used a device called a Silicon Controlled Rectifier (SCR) to make the alarm 'latch' on, so that it kept screaming even of the thief closed the lid again.

You could use that as the basis of an improvement to this circuit. Building the SCR latch section of the old project would allow you to make the LED in this project stay on so that if you are not near the sound, you will still know if someone has activated it. You would need the reset switch as well, but we do not recommend connecting the buzzer in this case. Leave that connected as a timed device as it is now, and just latch the light.