Light Sensing Switch

I’ve been a bit quiet recently. My last post was about controlling some lights with a sonic screwdriver with a Raspberry Pi handling everything. I’ve been expanding on it (which I will go into great detail in a later post) and one of the greatest tools I’ve found has been transistors. I’ve used them in the past but I’ve never really known what they actually do. It’s kind of embarassing because it’s so simple. In layman’s terms (and possibly the wrong description), a transistor is a sort of switch.

Your standard transistor is of the NPN type with three pins, collector, base, and emitter. A connection is made from the collector to the emitter when the base is given a high signal. What is so great about these little silicon wonders is they can do pretty much anything. Say you have a Raspberry Pi that will output only 3.3v and a small amount of current when one of its GPIO pins are high. Something like this could not flip a relay designed for 12V or drive a motor or something of the sort. We can use a transistor in its place to pass a larger amount of current and/or voltage to our component when the GPIO pin is high.

There’s tons of examples out there so you’ll have to just take a look yourself, but after experimenting with them I came up with the following schematic:


What this allows you to do is power an LED when a certain amount of light hits the light sensor (PH1). The amount of light needed to illuminate the LED is defined by R2. You’ll want to change it depending on the range of your light sensor’s minimum and maximum resistance values. To have the sensor more sensitive or have less amount of light needed to illuminate the LED, raise the value of R2. Less sensitive, lower the value. At 1K, the sensor is not very sensitive. It takes a large amount of light such as a super bright LED or laser to trigger.

That’s pretty much it. I thought it was very interesting how this worked so I decided to post about it. Now I shall go about reversing the results of this circuit so I can do more fun stuff with my Pi. Hopefully over the next couple days I will complete it and show you how I implemented it into my light project.

Leave a Reply

Your email address will not be published. Required fields are marked *