digitalfendi
Published © GPL3+

Super Simple Fun Laser Tripwire

A super simple, to-the-point laser tripwire.

BeginnerShowcase (no instructions)1 hour5,442
Super Simple Fun Laser Tripwire

Things used in this project

Hardware components

LED (generic)
LED (generic)
×2
Laser pointer
×1
Photo resistor
Photo resistor
×1
Buzzer
Buzzer
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Story

Read more

Schematics

laser_trip_wire_sketch_bb_Dl6qVfO4L7.png

img_0406_rKU3bzRBu9.MOV

Code

Untitled file

C/C++
/ code written by: DigitalFendi Enjoy :)


int ledPin1 = 2; // green led pin(2)
int ledPin2 = 4; // red led pin(4)
int buzzerPin = 5; // buzzer pin(5)
int lightReader = A0; // photoresistor pin(A0)
int freq = 2000; // frequency for the buzzer (change # to effect the sound of buzzer)
int x = 0; // initial value for x


void setup() 
{
  Serial.begin(9600);
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(buzzerPin, OUTPUT);
  pinMode(laserPin, OUTPUT);
  pinMode(lightReader, INPUT);
}

void loop() 
{
  
  x = analogRead(lightReader); // this is for serial monitoring purpose
  Serial.print("Reading: "); 
  Serial.println(x);
  

  if (x < 800) // if link between laser and photoresistor... (check serial monitor and change this # to your liking) 
    {
      digitalWrite(ledPin1, LOW); // turn green led off
      digitalWrite(ledPin2, HIGH); // turn red led on
      tone(5, freq); // buzzer sounds
    }
  else // if laser link is in tact...
    {
      digitalWrite(ledPin1, HIGH); // turn green led on
      digitalWrite(ledPin2, LOW); // turn red led off
      noTone(5); // buzzer does not sound
    }
}

Credits

digitalfendi

digitalfendi

1 project • 0 followers

Comments