user768408731
Published

Laser Trip Wire

We got our inspiration from a project on hackster.io and challenged ourselves to recreate it.

BeginnerShowcase (no instructions)1 hour1,357
Laser Trip Wire

Things used in this project

Story

Read more

Schematics

fritzing schematic

fritzing schematic

Code

code for alarm

Arduino
int btn;
int d4 = 294;
int photo;

void setup() {
  // put your setup code here, to run once:
  pinMode(7, INPUT);
  pinMode(2, OUTPUT);
  pinMode(8, INPUT);
  pinMode(9, OUTPUT);
  pinMode(3, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  btn = digitalRead(8);
  if(btn == LOW)
  {
    digitalWrite(9, HIGH);
    delay(500);
    photo = analogRead(0);
    Serial.println(photo);
   while(photo > 700)
    { 
    photo = analogRead(0);
    Serial.println(photo);
    }
  
   
    tone(3, d4);
    delay(500); 
    noTone(3);
    delay(50);
     tone(3, d4);
    delay(500); 
    noTone(3);
    delay(50);
     tone(3, d4);
    delay(500); 
    noTone(3);
    delay(50);
     tone(3, d4);
    delay(500); 
    noTone(3);
    delay(50);
   //add more beeps if you want
    
  }

}

Credits

user768408731

user768408731

1 project • 0 followers
Thanks to Nick Perry and Mario DiMatteo.

Comments