mmgamitocVrcg03
Published

Laser Beam Alarm

An alarm that triggers a siren sound an police lights when the beam of light is interrupted.

BeginnerWork in progress22,912
Laser Beam Alarm

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Breadboard (generic)
Breadboard (generic)
×1
Resistor 330 ohm
Resistor 330 ohm
×3
5 mm LED: Red
5 mm LED: Red
We used a red one and a blue one to resemble police lights.
×2
Jumper wires (generic)
Jumper wires (generic)
×1
Buzzer
Buzzer
×1
Pushbutton
×1
Photo resistor
Photo resistor
×1
Laser pointer
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Laser Alarm Schematic

Laser Alarm Schematic

Code

Laser Alarm

C/C++
Just adjust the sensivity to match your laser pointer's power.
To reset the alarm just push the button.
/*
A laser pointer is needed to make a light beam that will be detected by the ldr
Make Sure you line up the beam and the ldr properly
*/
const int sensivity = 400;  // 0-1023 a lower value means a more powerful laser

#define ldr A0
#define redLed 7
#define blueLed 8
#define buzzer 9
#define buttonPin A2


int buttonState;
int state = 0;


void setup() {
  alarmOFF();
  Serial.begin(9600);
  pinMode(redLed, OUTPUT);
  pinMode(blueLed, OUTPUT);
  pinMode(buzzer, OUTPUT);
}

void loop() {
  int light = analogRead(ldr);
  int button = analogRead(buttonPin);
  Serial.print("button = ");
  Serial.print(button);
  Serial.print("\n");  
  Serial.print("light = ");
  Serial.print(light);
  Serial.print("\n");  
  Serial.print("state = ");
  Serial.print(state);
  Serial.print("\n"); 
  Serial.print("\n");  
  if (button >= 1020) {
    state = 0;
  }
  if (light > sensivity) {
    state = 1;
  }
  if ((light <= sensivity) && (state == 0)) {
    alarmOFF();
  }
  if (state == 1) {
    alarmON();
  }
}


void alarmON() {
  tone(buzzer, 1760);
  digitalWrite(redLed, HIGH);
  digitalWrite(blueLed, LOW);
  delay(500);
  tone(buzzer, 1319);
  digitalWrite(blueLed, HIGH);
  digitalWrite(redLed, LOW);
  delay(500);
}

void alarmOFF() {
  noTone(buzzer);
  digitalWrite(redLed, LOW);
  digitalWrite(blueLed, LOW);
}

Credits

mmgamitoc

mmgamitoc

1 project • 3 followers
Vrcg03

Vrcg03

2 projects • 3 followers

Comments