Introduction: Automatic Light Fence Circuit With Alarm

Hello everyone. Here I am back with a new instructable.

A light fence circuit is used to detect the presence of any human or object in a particular area. The detecting range of Light Fence Circuit is about 1.5 to 3 meters.

It’s quite simple to design the circuit using LDR and Op-amp. This portable circuit can work smoothly with a commonly available 9V battery and the alarm sound generated from the buzzer is loud enough to detect the presence of a human, vehicle or object.

Step 1: Required Hardware

The following components have been used:

  • LM741 Op-amp IC
  • 555 timer IC
  • BC557 – PNP Transistor
  • LDR
  • Resistor (210, 1K, 5.7K, 100k, 1M)
  • Capacitor (0.1uf, 10uf)
  • Potentiometer – 100K
  • Buzzer
  • LED
  • Battery - 9V

Step 2: Circuit Schematic & Working


The complete circuit diagram for Automatic Fence Lighting with Alarm is shown above. LDR is placed facing towards the entrance and a potentiometer is used to adjust the sensitivity of the device. You can also add a switch between the negative pin of the battery and LDR’s grounded pin to control this security system manually.

Here, the op-amp IC is used as a voltage comparator and the 555 timer IC is placed in an astable mode. The LDR and the potentiometer are creating a voltage divider circuit. The output of this divider circuit will change according to the intensity of light falls on the LDR. The divider is connected to the inverting pin of the Op-amp IC. The non-inverting pin is connected with supply through a 5.7Kohm resistor, so the voltage value at the non-inverting is fixed. You can replace this resistor with a 10K potentiometer to adjust the voltage as per the requirement.

We can adjust the sensitivity of the device by using the potentiometer VR1 connected in series with the LDR. When the voltage at the non-inverting input is greater than or equal to the reference voltage the output (at pin 6) of the op-amp IC output (PIN 6) goes HIGH. Learn more about the working of op-amp by following the various op-amp based circuits.

According to the circuit diagram, when LDR detects any activity the output of the Op-amp IC goes LOW and PNP transistor T1 start conducting. Hence, the LED starts glowing and the 555 timers IC gets triggered. Here, 555 timer IC is in Astable mode and a present time delay is provided by R3, R5, and C1.

So whenever some person or object enters in a prohibited area, his shadows will be sensed by the LDR and the circuit triggers the alarm.

Step 3: PCB Design

The above figure shows the PCB design of Automatic Light Fence Circuit with Alarm using Eagle software.

Parameter consideration for PCB design

1. Trace width thickness is minimum 8 mil.

2. The gap between plane copper and copper trace is a minimum of 8 mil.

3. The gap between a trace to trace is a minimum of 8 mil.

4. Minimum drill size is 0.4 mm

5. All the tracks which have current path need thicker traces.

Step 4: Fabrication of the PCB

As most of my readers will know I always go for LIONCIRCUITS. They provide good quality PCBs at reasonable prices. Also, free shipping in INDIA.

I have my Gerber ready and waiting for the fabricated boards to write a PART-2 of this instructable.

Please message me if you guys need the Gerber file.