Build a Simple Shadow Alarm! | Photoresistor + 2N2222 + Buzzer
John 8:12 (KJV)
12 Then spake Jesus again unto them, saying, I am the light of the world: he that followeth me shall not walk in darkness, but shall have the light of life.
In this project, we’ll build a simple shadow alarm using a photoresistor, a voltage divider, a 2N2222 NPN transistor, and a 5 V active buzzer.
When light shines on the photoresistor, the alarm stays quiet. When something blocks the light and casts a shadow over the photoresistor, the buzzer sounds.
Components
- Photoresistor / LDR
- 10 kΩ resistor (R1)
- 10 kΩ base resistor (RB)
- 2N2222 NPN transistor
- 5 V active buzzer
- Breadboard
- Jumper wires
- Approximately 5 V DC power supply
- Multimeter
My power supply measured approximately 5.04 V during the project.
What Is an LDR?
LDR stands for Light-Dependent Resistor.
A photoresistor changes resistance depending on the amount of light striking it:
More light → Lower resistance
Less light → Higher resistance
In my setup, I measured approximately 1.07 kΩ under the normal light at my workbench and approximately 10–11 kΩ when I cast a shadow over the LDR.
Your values may be different depending on your particular photoresistor and the amount of light in the room.
How the Active Buzzer Works
An active buzzer contains the circuitry necessary to generate its own tone. We can apply the proper DC voltage to it and it produces sound without requiring us to build a separate oscillator.
A passive buzzer is different because it requires an external changing or oscillating signal.
How the Shadow Alarm Works
The photoresistor and R1 form a voltage divider.
For this circuit:
R1 = 10 kΩ
RB = 10 kΩ
Q1 = 2N2222 NPN
VCC ≈ 5.04 V
The voltage-divider node connects through the 10 kΩ base resistor to the base of the 2N2222.
The transistor’s emitter connects to ground. The active buzzer connects between the positive supply and the transistor’s collector.
When the transistor is OFF, the current path through the buzzer is open and the buzzer remains quiet.
When the transistor turns ON, current can flow:
+5 V → Active Buzzer → Collector → Emitter → Ground
The buzzer sounds.
Voltage Divider Equation
The basic voltage-divider equation is:
VNODE=VCC(RLDRR1+RLDR)V_{NODE}=V_{CC}\left(\frac{R_{LDR}}{R_1+R_{LDR}}\right)VNODE is the voltage at the junction between R1 and the photoresistor.
We call this VNODE rather than transistor base voltage because a separate 10 kΩ base resistor sits between the divider node and the base of the transistor.
Light Condition
Under the normal light at my workbench, the photoresistor measured approximately:
RLDR=1 kΩR_{LDR}=1\,k\OmegaUsing:
VCC=5.04VV_{CC}=5.04V R1=10 kΩR_1=10\,k\Omegawe calculate:
VNODE=5.04(1k10k+1k)V_{NODE}=5.04\left(\frac{1k}{10k+1k}\right) VNODE≈0.458VV_{NODE}\approx0.458VRounded:
VNODE≈0.46V\boxed{V_{NODE}\approx0.46V}This voltage is too low to turn the 2N2222 on, so the transistor remains OFF and the buzzer remains OFF.
Shadow Condition
When a shadow is cast over the photoresistor, its resistance increases. Using approximately:
RLDR=10 kΩR_{LDR}=10\,k\Omegawe calculate:
VNODE=5.04(10k10k+10k)V_{NODE}=5.04\left(\frac{10k}{10k+10k}\right) VNODE=2.52V\boxed{V_{NODE}=2.52V}The higher divider voltage can now supply base current through the 10 kΩ base resistor.
The 2N2222 turns ON, completing the current path through the active buzzer.
Shadow → Higher LDR resistance → Higher VNODE → Transistor ON → Buzzer ON
Why Use the 10 kΩ Base Resistor?
The main purpose of the 10 kΩ base resistor is to limit the current flowing into the base of the 2N2222.
It also helps reduce the amount that the transistor loads our voltage divider.
Although R1 and RB are both 10 kΩ, they perform different jobs in the circuit.
Loaded vs. Unloaded Voltage Divider
Our calculated values of 0.46 V in the light and 2.52 V in the shadow come from the basic unloaded voltage-divider equation.
Once we connect the transistor branch through the 10 kΩ base resistor, however, the divider is no longer perfectly unloaded.
When the transistor begins conducting, current also flows through the base branch. Therefore, the voltage we measure in the actual circuit may be different from the ideal value we calculated.
And that’s exactly what we discovered in the lab!
Actual Lab Measurements
Light
Calculated VNODE:
0.46V0.46VMeasured VNODE:
0.47V\boxed{0.47V}That’s extremely close to our ideal calculation.
Shadow
Ideal calculated VNODE:
2.52V2.52VMeasured VNODE:
1.42V\boxed{1.42V}The measured value is lower than the ideal calculation because the transistor/base-resistor branch is loading the voltage divider.
We also measured approximately:
VB≈0.65V\boxed{V_B\approx0.65V}at the transistor base with the shadow over the photoresistor.
That is enough base-emitter voltage for the transistor to conduct and switch our buzzer on.
Improving the Sensitivity
I originally tried a 47 kΩ resistor for R1.
The circuit worked, but it wasn’t as sensitive as I wanted. I wanted the buzzer to activate when I simply cast a shadow over the photoresistor.
After measuring the actual LDR, I found approximately:
Light: ≈ 1 kΩ
Shadow: ≈ 10 kΩ
I changed R1 from 47 kΩ to 10 kΩ, and the circuit became much more sensitive to a shadow.
This demonstrates an important part of circuit design:
Measure → Calculate → Change a Component → Test Again
The first component value we try isn’t always the best value.
What We Learned
This project combines several basic electronic building blocks into one useful circuit.
The photoresistor changes resistance with light. The voltage divider converts that resistance change into a voltage change. The base resistor limits transistor base current. The 2N2222 operates as an electronic switch, and the active buzzer produces our alarm sound.
We also saw an important difference between an ideal calculation and an actual connected circuit.
Calculations give us a great starting point, but then we build the circuit, measure it, and see what actually happens.
That’s part of the fun of electronics!
Final Circuit Values
Supply: ≈ 5.04 V
R1: 10 kΩ
RB: 10 kΩ
LDR in light: ≈ 1 kΩ
LDR with shadow: ≈ 10 kΩ
Transistor: 2N2222 NPN
Buzzer: 5 V active buzzer
Thanks for visiting Build Circuits With Rich!
Build the circuit, experiment with it, take some measurements, and see what improvements you can make.
Whoo Buddy!! ⚡🔧
My Notes:
Video Notes
Lab Notes
Want more electronics lessons?
For more beginner-friendly electronics lessons, circuit walkthroughs, and hands-on breadboard builds, visit:
https://buildcircuitswithrich.com
Prefer video?
Watch full lessons on the Build Circuits With Rich YouTube Channel.
Back To: Videos