Starting Electronics needs your help! Please make a donation to help cover our hosting and other costs. Click the donate button to send a donation of any amount.

Donations Received:

Tutorial 11: Light Activated Alarm

Created on: 3 August 2012

When enough light falls on the LDR in this circuit, an alarm tone is played on the loudspeaker. This is a four transistor circuit.

The video below shows what you will achieve in this tutorial.

Can't see the video? View on YouTube →


Complete Tutorial 8: Dual LED Flasher and its prerequisites before attempting this tutorial. Read about LDRs if you have not used one yet.


In addition to an electronic breadboard, wire links, a 9V battery and a battery clip, you will need:

Qty Part Designator Notes Type
3 10k resistors (brown - black - orange) R3, R4, R7 1/4W, 5% or better Resistors
1 4k7 resistor (yellow - violet - red) R6
1 2k2 resistor (red - red - red) R8
1 1k5 resistor (brown - green - red) R1
1 1k resistor ( brown - black - red) R2
1 330Ω resistor (orange - orange - brown) R5
2 100n C1, C2 Capacitor
3 PN2222 or KSP2222 Q2, Q3, Q4 NPN transistors Semiconductor
1 PN2907 Q1 PNP transistor
1 LDR R9 Light dependent resistor Transducer
1 8Ω loudspeaker SP1

Books that may interest you:

C Programming with Arduino Book Ultimate Arduino MEGA 2560 Hardware Manual Ultimage Arduino Uno Hardware Manual

Circuit Diagram

The circuit diagram looks more complicated than in previous tutorials, but can be thought of as two parts. The right half of the circuit is very similar to Tutorial 8: Dual LED Flasher. This part of the circuit produces the tone on the loudspeaker.

The left part of the circuit is the trigger that switches the right part of the circuit on when enough light falls on the LDR.

Light activated alarm circuit diagram

The breadboard used in projects on this website has top and bottom horizontal rails (or connecting strips) that are split in the middle. The right half of the circuit will be built between the right horizontal rails and the left half between the left horizontal rails. The top rail of the circuit is shared by both halves, so the top left and top right rails will be joined by a wire link.

The collector of transistor Q2 will join to the right bottom rail as shown in the circuit diagram. All the ground points of the left part of the circuit will share the left bottom horizontal rail.

Building the Circuit

Insert two PN2222 transistors – Q3 and Q4. Connect the emitter of each transistor to the bottom rail of the breadboard. Get R2 (1k) and R5 (330R) ready.

Insert the transistors

Connect R2 to the collector of Q3. Connect the other lead of R2 to the top rail using a wire link. Connect R5 to the top rail in line with the collector of Q4 below. The loudspeaker will be connected between R5 and the collector of Q4 later. Get C1 and C2 ready (100n capacitors).

Insert resistors

Connect C1 to the collector of Q3. The spare lead of C1 is to be to the right. Connect C2 to the collector of Q4. The spare lead of C2 is to be to the left with two empty tie points between its left and right pins. Get R3 and R4 ready (10k resistors).

Insert capacitors

Connect R3 to C1 and R4 to C2. The other end of each resistor is to be placed above the middle of the breadboard and connected to the top rail using wire links. Get two wire links ready.

Insert resistors

Connect the C1 - R3 junction to the base of Q4. Connect the C2 - R4 junction to the base of Q3. Get Q2 ready (PN2222 transistor).

Insert wire links

Insert Q2 into the breadboard between the left top and bottom rails. Connect the emitter of Q2 to the bottom left rail. Join the left and right top rails with a wire link. Get R8 (2k2) ready. R8 is blue in colour here as it is a 1% tolerance resistor. Just use a normal 5% tolerance resistor. The 1% tolerance resistor was only used because a 5% tolerance resistor was not available.

Insert transistor

Connect the 2k2 resistor (R8) to the base of Q2. Connect the collector of Q2 to the right bottom breadboard rail. Get Q1 ready (PN2907 transistor).

Insert wire link and resistor

Insert Q1 so that its collector connects to R8. Connect the emitter of Q1 to the top breadboard rail. Get R7 ready (10k resistor).

Insert transistor

Connect R7 to the collector of Q1 and to the bottom left rail using two wire links. Get the 1k5 resistor ready.

Insert resistor

Connect the 1k5 resistor (R1) to the base of Q1 and to the top rail. Get the LDR and 4k7 resistor ready.

Insert resistor

Connect the 4k7 resistor (R6) to the base of Q1. Connect the LDR to the other end of R6 and to the left bottom rail. Get the loudspeaker and battery ready.

Insert resistor and LDR

Connect the positive lead of the loudspeaker to R5 and the negative lead to the collector of Q4. Connect the negative lead of the battery to the left bottom rail and the positive lead of the battery to the top rail.

The finished light activated alarm breadboard circuit

Operating the Circuit

After connecting the battery to the circuit, the loudspeaker should start producing the alarm tone. Cover the LDR to stop light from reaching it and the alarm will stop sounding.

To trigger the alarm, uncover the LDR and the alarm will start sounding.

← Go back to Tutorial 10: Ten Arduino Projects for Absolute BeginnersGo to Tutorial 12: Arduino LCD →