{"title":"Laser Detector module","handle":"laser-detector-module","url":"/products/laser-detector-module","description":"Laser Detector Module\nWant 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.&nbsp; Shine a laser at the SensorAdd power to 5V to VCC, Ground to GND and plug your middle pin into D2Add a Buzzer on D8 and GND// --- Pins ---const int RX_DO_PIN &nbsp; = 2; &nbsp; // Receiver DO -&gt; D2const int LED_PIN&nbsp; &nbsp; &nbsp;= 13;&nbsp; // On-board LED for feedbackconst int BUZZER_PIN&nbsp; = 8; &nbsp; // Active buzzer -&gt; D8// --- Tuning ---const unsigned long STABLE_MS = 40;&nbsp; // require this much stable time to accept changeconst unsigned long POLL_MS &nbsp; = 2; &nbsp; // 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() {&nbsp; if (USE_INPUT_PULLUP) {&nbsp; &nbsp; pinMode(RX_DO_PIN, INPUT_PULLUP);&nbsp; } else {&nbsp; &nbsp; pinMode(RX_DO_PIN, INPUT);&nbsp; }&nbsp; pinMode(LED_PIN, OUTPUT);&nbsp; pinMode(BUZZER_PIN, OUTPUT);&nbsp; digitalWrite(BUZZER_PIN, LOW); &nbsp; // buzzer off&nbsp; Serial.begin(115200);}// Helper to read \"laser seen?\" abstracting the optional inversionbool rawLaserSeen() {&nbsp; int v = digitalRead(RX_DO_PIN);&nbsp; if (USE_INPUT_PULLUP) {&nbsp; &nbsp; return (v == LOW); &nbsp; // LOW means detected when pull-up is used&nbsp; } else {&nbsp; &nbsp; return (v == HIGH);&nbsp; // HIGH means detected on actively-driven outputs&nbsp; }}void loop() {&nbsp; static bool stableState = false;&nbsp; &nbsp; &nbsp;// debounced belief&nbsp; static bool lastSample&nbsp; = false;&nbsp; &nbsp; &nbsp;// last raw sample&nbsp; static unsigned long lastChangeMs = 0;&nbsp; bool sample = rawLaserSeen();&nbsp; if (sample != lastSample) {&nbsp; &nbsp; lastSample = sample;&nbsp; &nbsp; lastChangeMs = millis();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// raw level changed; restart stability timer&nbsp; }&nbsp; if ((millis() - lastChangeMs) &gt;= STABLE_MS &amp;&amp; sample != stableState) {&nbsp; &nbsp; stableState = sample;&nbsp; &nbsp; if (stableState) {&nbsp; &nbsp; &nbsp; Serial.println(\"Laser detected\");&nbsp; &nbsp; &nbsp; digitalWrite(LED_PIN, HIGH);&nbsp; &nbsp; &nbsp; digitalWrite(BUZZER_PIN, LOW); &nbsp; // &lt;&lt;&lt; turn buzzer on&nbsp; &nbsp; } else {&nbsp; &nbsp; &nbsp; Serial.println(\"No laser\");&nbsp; &nbsp; &nbsp; digitalWrite(LED_PIN, LOW);&nbsp; &nbsp; &nbsp; digitalWrite(BUZZER_PIN, HIGH);&nbsp; &nbsp; // &lt;&lt;&lt; turn buzzer off&nbsp; &nbsp; }&nbsp; }&nbsp; delay(POLL_MS);}","vendor":"Little Bird","product_type":"physical","in_stock":true,"options":[],"variants":[{"id":207,"title":"Default Title","sku":"LB-LS1177","price":3.95,"compare_at_price":0.0,"on_sale":false,"in_stock":true,"available_quantity":117,"option1":"Default Title"}]}