Introduction: Arduino Laser System-Tripwire Tutorial

I made it using an Arduino, a laser diode, a photocell (light dependent resistor) and a piezo buzzer.



Code :


const int PHOTOCELL_PIN = A0;
const int BUZZER_PIN = 3;
// voltage readings are in 0-1023 range
const int THRESHOLD = 500;

void setup() {
  pinMode(PHOTOCELL_PIN, INPUT);
  Serial.begin(9600);
}

long alarmEndTime = 0;

void loop() {
  int level = analogRead(PHOTOCELL_PIN);
  Serial.println(level);
  long time = millis();
  if (time < alarmEndTime) {
    long timeLeft = alarmEndTime - time;
    if (timeLeft % 1000 > 300) {
      tone(BUZZER_PIN, 4000);
    } else {
      noTone(BUZZER_PIN);
    }
  } else {
    noTone(BUZZER_PIN);
    if (level < THRESHOLD) {
      alarmEndTime = time + 3000;
    }
  }
}

 


Comments

author
HelmutHound made it!(author)2013-06-05

Isn't this more of a "light alarm," rather than a "laser trip wire?"

author
vicvelcro made it!(author)2013-06-06

It looks fine to me. When the beam is interrupted, an alert sounds. Laser trip wire. I think I'll be adding one of these to my laser work area. With the compressor and exhaust fan noise, I never hear people approach. A few mirrors should suffice for a single laser to cover 3 sides of a 12' perimeter. An LED at eye level, to supplement the audible alert, and I should be all set.

About This Instructable

7,393views

28favorites

License:

More by 100FUBU100:Arduino Remote RGB LED by Visual BasicArduino Laser System-Tripwire Tutorial
Add instructable to: