Introduction: Infrared Tripwire

110 Volt Source.

Supplies

QED123 (IR LED) $0.58 per

https://www.digikey.com/product-detail/en/on-semic...

QSD123 (IR reciever) $0.54 per

https://www.digikey.com/product-detail/en/on-semic...

Relay Module $5.50 single Amazon

Male to female wires under $6 Amazon

Female to female wires under $6 Amazon

(2) 220 ohm resistors around $0.049 each

14 Gauge Wire around $0.10 per ft

LED Light bulb $1 1000bulbs.com

Bergen Keyless Lampholder $2.74 1000bulbs.com

Wire stripper $7 Amazon

Breadboard $8 Amazon

Step 1: Wire the Breadboard

Wire a 220 ohm resistor in series with the QED123 (LED/pinkish) on the breadboard. On the opposite side of the breadboard, do the same with the QSD123 (Black).

Then connect a male to female wire(mtf) from the 5 volt pin of the pi to the same row of the resistor connected to the QED. Again connect a wire from another 5 volt pin on the pi to the resistor connected to the QSD. Then connect two mtf wires from ground pins on the pi to the rows of the other sides of QSD and the QED. Then take an mtf wire from the row where the QSD(black) and resistor share and connect it to a regular GPIO pin. I used pin 11(GPIO 17).

Then connect a Female to female (FTF) wire from a 3.3 volt pin to the vcc pin of the relay.Then connects a FTF wire from a ground pin to the GND pin of the relay. Lastly connect a FTF wire from a normal GPIO of your choice to the last pin on the module.

Step 2: Wire Relay Module

*strip the end of the wires*

Use 14 gauge (stripped at each end) from the silver screw of the lamp holder to the NO(normally open) on the relay module. Then wire from the gold screw to a 120volt source Negative. Then wire from the COM of the relay module to the to the positive of the 120 volt source.

Step 3: Coding

*The relay module is turned on with a logic low/0 so the if statement*

Set the GPIO connected to the QSD as an input and the GPIO connected to the relay module as and output.

Create two if statements both monitoring the input of the GPIO connected to the QSD. One triggered by a high and the other as a low. I both print what is happening with the tripwire. When the tripwire is blocked set off the relay and stop the code with gpio.cleanup( ) so the light stays on to show the tripwire has been broken