| PIR sensor on the breadboard for testing the code which follows | Parts Required One K76 PIR sensor (PIR module KC7783 or KC778B) Google to find best prices One 10 K ohm resistor Three connector wires | Schematic for PIR circuit | Instructions on building - Make sure the board is turned off.
- Be very careful to have the sensor’s polarities correct for power and ground. You will notice on the back of the sensor in small writing, where the three wires meet the board, that it says V+, out, and Gnd
- Remove your SSR from the output pins.
- Place the PIR in the board
- Wire in the 10 K ohm resistor between the ground and output pins of the PIR, and also connect the PIR ground to the Board’s ground with a connector wire and the PIR output to the Boards’s P0
- Connect the V+ pin of the PIR to Vdd on the Board.
Programming the Project: In this program, you will learn to program the PIR sensor to turn on and off and communicate with your debug window. The program considers the length of time the sensor needs to recover. PART 1: PROGRAMMING A PASSIVE INFRARED SENSOR Enter the program below:
' {$STAMP BS2} ' {$PBASIC 2.5}
INPUT 0 ‘Defines pin 0 as an input Sense: ‘”Sense” is a label in the program IF (IN0 = 1) THEN sensor_activation 'look to see if PIR has detected something ‘and made pin 0 high, and if is true then go to ‘sensor_activation GOTO sense 'if pin 0 is not high return to start of ‘program sensor_activation: DEBUG “sensor activation " 'display sensor_activation in debug ‘window, will stay high for 1 second after ‘activated. PAUSE 1200 'wait 1.2 sec so that a display happens ‘once for each detection giving the sensor ‘time to go low again. GOTO sense 'return to start of program and look for ‘sensor being activated PART 2: changing the area of sensing that the pir can see Modifying the PIR sensor In this activity, you will turn the PIR sensor into a shotgun sensor. The PIR, with the Fresnel lens, allows you to mount this sensor on the ceiling and see in a full 360-degree area. However, what if you wanted to sense in only a 180-degree area? Well, one trick is to paint out portions of the Fresnel lens. For example, in order to allow it to see only 180 degrees, you would paint out half of the sensor. I recommend acrylic paint for this and make sure it is thick enough to block the infrared heat from you infrared sources. You can also change the sensor into a shotgun sensor by putting a piece of brass tubing 3/4 inch long over the heat sensor. Parts necessary One K76 PIR sensor (PIR module KC7783 or KC778B) Google to find best prices One small brass tube (step tubing) - Carefully remove the Fresnel cap that is covering the sensor. You will notice a round can-shaped form with a rectangular window. Notice, as well, the capacitors on each side.
| | Fresnel lens coming off the PIR sensor Model by Jessica Miller | PIR sensor revealing heat sensor and two Capacitors . Model by Jessica Miller |
| PIR sensor with a small tube of one inch long cut to fit over the cover of the sensor. It must slip over the sensor can and be careful not to use glue here as it can creep onto the sensing window of the PIR sensor. |
- Now, take the Fresnel lens, put it over your eye, and turn your head while looking at a light source.
- Notice how the light jumps from one window to the next in the lens?
- When the lens is attached to the sensor, this is how it is imaging infrared heat onto the can-shaped pyroelectric sensor inside.
- Place the small tubing that came with your kit over top of the sensor.
- Run the program entered previously and notice how the sensor will only sense in a narrow beam where you point your tube?
- Remember to give the sensor 25 seconds to warm up.
|