Store

Little Bird

$3.95 |
In stock
No reviews yet

Laser Detector Module Want to set up your own laser tripwire? These little modules make it super simple. Just hook one up to your Arduino, line it up with a ...

Estimated Delivery
Arrives
Disclaimer
View Markdown
Secure checkout
Laser Detector Module
Want to set up your own laser tripwire? These little modules make it super simple. Just hook one up to your Arduino, line it up with a laser pointer, and you’ve got a working laser detection system. Add a buzzer or LED and it’ll trigger the moment someone breaks the beam. Perfect for security projects, spy gadgets, or just a fun electronics experiment.


Here is some quick code to get you up and running.  Shine a laser at the Sensor

Add power to 5V to VCC, Ground to GND and plug your middle pin into D2

Add a Buzzer on D8 and GND



// --- Pins ---
const int RX_DO_PIN   = 2;   // Receiver DO -> D2
const int LED_PIN     = 13;  // On-board LED for feedback
const int BUZZER_PIN  = 8;   // Active buzzer -> D8

// --- Tuning ---
const unsigned long STABLE_MS = 40;  // require this much stable time to accept change
const unsigned long POLL_MS   = 2;   // sampling interval

// Set this to true if your module needs a pull-up (some boards are open-collector)
const bool USE_INPUT_PULLUP = true;

void setup() {
  if (USE_INPUT_PULLUP) {
    pinMode(RX_DO_PIN, INPUT_PULLUP);
  } else {
    pinMode(RX_DO_PIN, INPUT);
  }
  pinMode(LED_PIN, OUTPUT);
  pinMode(BUZZER_PIN, OUTPUT);
  digitalWrite(BUZZER_PIN, LOW);   // buzzer off
  Serial.begin(115200);
}

// Helper to read "laser seen?" abstracting the optional inversion
bool rawLaserSeen() {
  int v = digitalRead(RX_DO_PIN);
  if (USE_INPUT_PULLUP) {
    return (v == LOW);   // LOW means detected when pull-up is used
  } else {
    return (v == HIGH);  // HIGH means detected on actively-driven outputs
  }
}

void loop() {
  static bool stableState = false;     // debounced belief
  static bool lastSample  = false;     // last raw sample
  static unsigned long lastChangeMs = 0;

  bool sample = rawLaserSeen();

  if (sample != lastSample) {
    lastSample = sample;
    lastChangeMs = millis();           // raw level changed; restart stability timer
  }

  if ((millis() - lastChangeMs) >= STABLE_MS && sample != stableState) {
    stableState = sample;

    if (stableState) {
      Serial.println("Laser detected");
      digitalWrite(LED_PIN, HIGH);
      digitalWrite(BUZZER_PIN, LOW);   // <<< turn buzzer on
    } else {
      Serial.println("No laser");
      digitalWrite(LED_PIN, LOW);
      digitalWrite(BUZZER_PIN, HIGH);    // <<< turn buzzer off
    }
  }

  delay(POLL_MS);
}

Jargon buster

Plain-language definitions for the technical terms used above.

LED
A light-emitting diode is a small electronic component that lights up when current flows through it in the correct direction. In this kit, LEDs create the flashing effect, so polarity and correct soldering matter for the project to work.
Stella
Stella Expert

Ask me anything about this product

Maddy, co-founder of Little Bird

Need help? We're here for you!

Hi, I'm Maddy. My team and I are ready to help with your order or any questions.