Another Arduino Laser Tripwire





Introduction: Another Arduino Laser Tripwire

This is my version of login258's laser tripwire at

I've made a couple of modifications: the laser is now independent from the Arduino so that it can be placed anywhere in the room and I've changed the LED to a buzzer.


Step 1: Parts

You will need:

Laser emiter, 3v battery and on/off switch OR Laser pointer and electrical tape

Photocell (a big one because it makes an easier target)
2 10k resistors
peizo buzzer
Battery to power the arduino with a jack
Various short jumpers
Elastic bands
Bored kids
Wet sunday afternoon

Step 2: Build the Circuit

Connect the peizo's positive wire to pin 11 via a 10k resistor and ground wire to ground on the breadboard.
Connect one leg of the photocell to the 5v pin on the arduino.
Connect the other leg to analog pin 0 AND to ground on the breadboard via the second 10k resitor.
Connect ground on the breadboard to ground on the arduino.
Plug the battery (I used 12v because that was what was to hand) into the arduino power jack when you want to use it away fronm the computer but to get it up and running it can take power through the USB for now.
Strap it all together with an elastic band.

If using a laser emitter wire it to a 3v battery pack and add lots of blu-tac to make aiming it easier later on.

Step 3: Calibration

Photocells differ so you need to calibrate yours to your laser. Run the following sketch from Login258 or use the one on the arduino website at

void setup() {
pinMode(4, OUTPUT);

void loop(){
digitalWrite(4, HIGH);

With the sketch running press Serial Monitor on the arduino window and make a note of the numbers that appear in the bottom of the window with the laser on the photocell and when it is off (ambient light).

Step 4: The Code

Upload the following sketch but adjust the value in the "if" statement to suit your photocell. Pick a number a bit above the ambient light number. This may need tweaking later, or, just pull a curtain or shrpud the photocell to lower the ambient light in the room.


int buzzPin = 11; // buzzer connected to digital pin 11

void setup() {
pinMode(buzzPin, OUTPUT); // sets the digital pin as output

void loop(){
if(analogRead(0) < 850){ // this number depends on calibration of the photocell
digitalWrite(buzzPin, HIGH); // turns buzzer on
delay(1000); // waits for 1 second
digitalWrite(buzzPin, LOW); // turns buzzer off

} else{
digitalWrite(buzzPin, LOW);



    • Epilog Challenge 9

      Epilog Challenge 9
    • Pocket-Sized Contest

      Pocket-Sized Contest
    • Science of Cooking

      Science of Cooking

    We have a be nice policy.
    Please be positive and constructive.




    hey I'm trynna make this and I've done the exact same thing but when there's no laser the buzzer sounds, and it sounds louder when the laser is shone. I've copy-pasted the code. Please help it's really important.

    I haven't looked at this since I posted it so am a bit rusty. It may be code is now deprecated and you need to find updated commands on the forums OR the cell is not calibrated as in Step 3. You need a clear differential in readings so the code knows what is high and what is low. If you copied the readings from my code they will be different for your laser and cell so won't work. Also I put my photocell down a short piece of plastic pipe to keep the cell in the shade which helped a lot.

    Can someone make an instructable to help me run a code on an Arduino Uno? If would be very helpful! Thanks.
    (I need fully detailed steps)

    1 start Arduino IDE
    2 open code you want
    3 connect Arduino to yr computer with USB cable
    4 in IDE select under 'Tools' the proper port and board
    5 press 'upload' in yr IDE

    Is there any code needed to make this work? Or can I just set it up & it will work?

    yes you need code, otherwise the arduino has no idea what you want

    I can't get easy access to cheap laser pointers in my region (west Africa) but I sure have hundreds of faulty CD and DVD players lying around. Could I make use of the laser module inside these players? If yes, would I have to remove their lens system or just use it as it comes? A quick answer will be appreciated.

    do you when the beam is broken, does the buzzer keep on buzzing or does it tur off after a while

    Thanks for the credit! I'm glad my Instructable actually made some sort of impact. Someone commented on mine and said that two photoresistors would work well, one for ambient light and one for the laser, so that's a good suggestion for you .