Step 5Building the contact closure
Remember the water closure circuit board? Well, I decided to use the door sensor pads to connect my sensor. So, here's what we're dealing with:
One of the pads is connected directly to ground. The other pad is connected to pin 19 on the PIC down on the skinny part of the board on the underside. That pin is a digital input/output pin. Now here's where I'm a bit confused, but I didn't let it stop me. Measuring the voltage on that pad, I get 0.85V. That's quite a bit lower than I expected. However, even with the lower than expected voltage, if I ground that pad, it activates the trigger. So, I just need to devise a circuit that will open and close this connection. A perfect task for a transistor.
I don't know much about transistors other than they are, at my most simple understanding, an electrically controlled on/off switch. You put enough voltage on the base and that causes electricity to flow between the collector and the emitter. That's all I know, and its projects like these that will help me learn more.
Now, we could just hook the photosensor up to the transistor, but we wouldn't get the effect we are going for, resistors limit current, not voltage. We want on and off states, black and white, not shades of gray and we want to control it with voltage. For photoresistors, a typical "on when dark" circuit uses what's called a voltage divider. It uses two resistors in series (one of them being the photoresistor) and the load of the circuit, a light in most cases, is connected to the point between the resistors. The voltage at that point is a fraction of the original voltage based on the proportion of R1/R2. Simple, right? I don't think so. I still can't get my head around why this even works, but it does.
Anyway, the base of the transistor is connected to the point in between the resistors. I learned this (and many other things) at Society of Robots website, specifically http://www.societyofrobots.com/schematics_photoresistor.shtml. Check it out. Good stuff. Not just for robot stuff, which is excellent, but for many things electrical, mechanical, and softwarical.
So, take a look at my schematic and try not to laugh. I'm learning, okay?
I have to power the sensor circuit from a power supply rather than just from the door sensor pad because there simply isn't enough voltage/current on that pad to trigger the transistor. I tried, oh, I tried and I couldn't get it to work. So, VCC and GND are connected to the battery terminals inside the water sensor module. SIG is connected to one of the door sensor pads. Make sure you connect it to the one that goes to the PIC, not the one that goes to GND.
To figure out what resistor you need for R2, grab the paper that you wrote Rdark and Rlaser on in the last step. Do this calculation:
R2 = sqrt(Rdark * Rlaser), then pick the closest resistor you have to that value.
The capacitor at C1 is optional. I added it to my board in case I wanted to adjust the reaction time of the trigger. This capacitor will cause the trigger to delay slightly. This is both good and bad. The good is that it protects you from false alarms when, lets say, the garbage man comes and creates vibrations in the air and ground that could misalign your laser for a split second. The capacitor will keep the sensor from tripping. The bad thing is that if you use too large a capacitor, your intruder could actually run right through your sensor without setting it off. I found that a 1uF capacitor worked pretty well. I could still pass through the sensor with a pencil without triggering it, but I doubt any intruder could even if they were aware of the laser (they'd just step over it. DOH!)
So, take a look at my circuit board, burned to a crisp and dripping with flux from all the iterations of...on the breadboard it works, on the circuit board it doesn't, back and forth, back and forth. Finally it works. Finally. Again, try not to laugh, but if you do, I understand. I'll laugh about it someday...when the psychological pain starts to fade.
Anywhoo, so it works. I've got it set up to protect my Girl Scout Cookies from my wife and daughters. Yeah, they're thin mints...like you even have to ask... ;-)
Update: For some reason the first circuit isn't working reliably. I am testing a second circuit that uses a 3V relay. A picture of the circuit has been uploaded, so check it out. I haven't built it yet, so stay tuned to see what happens.
More on how I have it set up in the next section.
| « Previous Step | Download PDFView All Steps | Next Step » |
![]() |
Add Comment
|














































