![]() |
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
Overview Images: |

| Step 1 | Step 2 | Step 3 | Step 4 |
|
Setup Requirements: |
Tools:
Screwdriver
Heat Gun (Blowdryer)
Soldering Iron
Solder
Wire Strippers
22 AWG (or similar) wireHardware/Components:
PIR sensor
Light (halogen or other)
PolyBlock
Power Supply
0.1 uF ceramic capacitor
A light that turns on only when somebody is nearby can save energy, can save you the hassle of searching for a lightswitch in the dark, or can also alert you to the presence of an unwanted visitor. A PIR sensor is an infrared motion detector and it is easily connected to a PolyBlock which, in Timer Mode, can turn a light on automatically for a specified period of time when somebody is within range.
The PIR sensor works by comparing the outputs of its two internal infrared sensors. With no motion within the sensor's range, these two internal sensors settle to an "off value". When a person (or other large infrared-producing body) comes within range, the values the two infrared sensors record changes from the off value, and the PIR interprets this as motion. The PIR sensor outputs a logical "1" or 5V on its output for a second or two after the motion stops. This is a weak digital signal so by itself it couldn't run a light (or anything, really bigger than a small LED) . We could connect it to a Switch Block, and thence to a large lamp, but this wouldn't help much either, since the PIR signal is only on for a few seconds after it detects movement. We'd like our light to be on for much longer.
What we need is something to stretch out the signal from the PIR sensor, so what we can do is connect the output of the PIR sensor to a Poly Block running the Timer function. The Timer function on the Poly Block works as follows: when a signal triggers it, the O0 output is turned on for a time period specified by the Poly Block's "Timer Duration" reference voltage. With the trimpot jumper attached, this voltage can be determined by the trimpot. This means that by adjusting the trimpot, the timer can be set to run for longer or shorter periods.
There are several ways to trigger the Timer. The "Trigger" (I0) input, starts the timer when the input goes from off (0V) to on (5V). The timer runs for this period and then turns off. While this might seem perfect, it is not quite right for this application. The reason is that we actually want the output to go on when someone is detected in the room (which would happen using the Trigger input), but we don't want the timer to start until the movement stops, otherwise the timer period might end while the person is stil moving around and the result would be an annoying plunge into darkness. To fix this, we use the "Sustain Trigger" (I2) instead. The sustain trigger is designed for exactly this kind of application - turn on immediately when triggered, but don't actually start the countdown to turn off until the triggering voltage has been removed.
This set up assumes that the PIR sensor will be located very close to the Poly Block - if you need to make long cable runs from the PIR to the Poly Block, take a look at the Line Block.
If you wanted to use an AC light, you could connect the O0 output to the AC Switch Block, and control the light from there. But beware, household AC voltages (110V or 220V depending on where you live) are very dangerous.
Fig. 2: Block Diagram
Step 1 - Connect the Power Supply
First we need to choose a light and an appropriate power supply. The main determining factor here is how much power the light is going to need. The +V connections will be determined by the voltage of the fan - i.e. a 12V light will require a 12V power supply. A smaller light that runs on 9V, for example, would make it possible to use a standard 9V battery as the power supply. Be sure to power the PIR sensor from the 5V connector on the PolyBlock, not +V. Note that an AC (110V) household light would definitely not work directly with this set up and would certainly damage any connected devices.
Depending on your choice of light, you'll need to choose an appropriate power supply, as mentioned above. With your power supply selected, connect the +V (positive) from the power supply to +V on the PolyBlock and the 0V (ground/negative) from the power supply to 0V on the PolyBlock (Fig. 1.1). You may need to strip 1/8" insulation off the wires from your power supply.![]() |
Fig.1.1 |
Step 2 - Connect the PIR Sensor
The PIR sensor has three wires coming out of it. The red wire goes to 5V on the PolyBlock, the black wire goes to 0V, and the yellow wire should be connected to I2 (Input 2) (Fig. 2.1). Set the PolyBlock to the Timer Function by manipulating the Function Switch to 0010 (Fig. 2.2). I2 on a Poly Block set to the Timer Function corresponds to the Sustain Trigger input. This means that as soon as the PIR is triggered, the light will turn on but the timer will not start counting down until the PIR is inactive. The length of the timer will determine the amount of time that the light remains on after nobody is in range of the PIR sensor.
![]() |
![]() |
|
Fig. 2.1 |
Fig. 2.2 |
Because halogen lights create electrical noise on the lines that power them, if we use them, it is important to filter the power going to them with a capacitor. The capacitor needs to go between the two wires going to the light and should be around 0.1uF and be rated to work with at least the +V voltage you're using.
To do this, we need to make one solder connection from the positive lead of the capacitor to the +V line going to the light, and another from the negative lead of the capacitor to the 0V (ground) line to the light. Solder a short length of wire (appropriately colored - black or red) onto each of the leads of the capacitor (Fig. 3.1 - below) and then use these wires to make the connection with the appropriate wires from the light. Heatshrink any exposed solder joints to prevent unwanted shorts and to add a little physical support.
Step 4 - Connect the Light
Assuming the chosen light is not going to draw more than 2A of current, it can be connected directly to the PolyBlock. If your light draws more than 2A of current, you can add a Switch Block to increase the allowed amperage. Connect the positive lead from the light to the +V connector on the Poly Block and the negative lead to the S0 (Switch 0) connector (Fig. 4.1). To connect a household lamp to a standard power outlet, please see the AC Switch Block. Again, be sure that your power supply provides the correct +V for the light you've chosen.
The output from the PolyBlock will come from the +V connector and the S0 (Switch 0) connector. Be sure not to use the O0 (Output 0) connector - the V+ line via the light will expose the microcontroller to voltages that will almost certainly damage it.
![]() |
![]() |
|
Fig 3.1 |
Fig. 4.1 |
Step 5 - Power Up
With the power supply still unplugged, double check all of the power connections to make sure all the 12V's, 5V's, and 0V's are properly connected. Once you're confident everything is where it should be, plug in the power.
Step 6 - Calibrate the PolyBlock
As described in the Timer Function reference for the PolyBlock, the onboard trimpot can be used to adjust the amount of time that the light will stay on once the PIR is triggered. This can range from anywhere from a few milliseconds to almost 20 minutes. Start with the trimpot turned all the way counter-clockwise. This will give you the shortest timer period possible. Gradually turn the trimpot clockwise to adjust the length of the timer as desired.
D.I.Y. Burglar Alarm - Turn on a light automatically when somebody enters a certain area. The light can either be located in the same space as the motion detector or be remote - turn on a light or LED indicator sin your room or office to let you know that somebody is at your front door.
Household Automation - Use the AC Switch Block to control a household lamp instead of one of its smaller relatives.
Flashing Light - Add a second Poly Block set to the Oscillator Function to make the light flash on and off when the PIR sensor is triggered.
If you make this project or one related to it, please post any questions, comments and/or pictures to our mailing list.
| copyright © 2002-2004 MakingThings LLC |