seen from United States
seen from Germany

seen from United States

seen from United Kingdom
seen from Italy
seen from United States
seen from Kazakhstan

seen from United States
seen from China

seen from Türkiye
seen from Switzerland

seen from Türkiye
seen from United States
seen from United Kingdom
seen from China

seen from United States

seen from United States
seen from United States

seen from Australia
seen from United Kingdom
Arduino Laser Trip Wire with Auto Ambient Light Calibration
I am still waiting for my LCD screens and IR sensors to turn up, so in the meantime I built a laser trip wire that auto calibrates the trip thresholds after (x) seconds or after being tripped.
The code runs for the first time and creates a running average of the ambient light via the light sensor. This average will be higher if you point a laser at it like I have in the photo.
Every (x) seconds (10 seconds in the code below) it calculates the current average for ambient light via a rolling average. When the light sensor is tripped, it resets the array and calculates the average from scratch.
The LED on pin 13 shows when the trap is active (HIGH) and can be tripped. When the LED is LOW, the auto-calibration is occurring or the trap is in a wait state (3 seconds in code) to prevent multiple triggers..
Update: Fixed an error in the following diagram.
/************************************************************************************ * * Name : Laser trip wire with auto-recalibration sketch * Author : Brock Cremer * Updated : August 14, 2014 * Version : 0.1 * Notes : * URL : http://timecircuit.tumblr.com * ***********************************************************************************/ const int numReadings = 10; // number of readings to calculate average in averageAnalog() int readings[numReadings]; // the readings from the analog input in averageAnalog() int index = 0; // the index of the current reading in averageAnalog() int total = 0; // the running total in averageAnalog() int average = 0; // the average in averageAnalog() int inputPin = A0; // analog input pin int delayAfterTrigger = 3000; // wait period after being triggered unsigned long interval=10000; // the time we need to wait unsigned long previousMillis=0; // millis() returns an unsigned long. void setup() { // initialize serial communication with computer: Serial.begin(9600); // initialize all the readings to 0: for (int thisReading = 0; thisReading < numReadings; thisReading++) readings[thisReading] = 0; // use LED pin 13 to show when trigger is active pinMode(13, OUTPUT); digitalWrite(13, HIGH); for (int i = 0; i < numReadings; i++) { averageAnalog(); } Serial.println("Initilisation Complete..."); Serial.print("\r\n"); } void loop() { // Nothing will change until millis() increments by 10000 // Read ambient and calculate average light if ((unsigned long)(millis() - previousMillis) >= interval) { previousMillis = millis(); averageAnalog(); digitalWrite(13, HIGH); } if(analogRead(inputPin) < average * 0.8) { Serial.print("Triggered at: "); Serial.print(millis()); Serial.print("\r\n"); Serial.println("Waiting..."); digitalWrite(13, LOW); delay(delayAfterTrigger); // delay in between reads to prevent multiple triggers for (int i = 0; i < numReadings; i++) { averageAnalog(); } digitalWrite(13, HIGH); Serial.println("Trigger Ready..."); Serial.print("\r\n"); } } int averageAnalog() { // turn the LED on pin 13 off to show that the average is being calculated digitalWrite(13, LOW); // subtract the last reading: total= total - readings[index]; // read from the sensor: readings[index] = analogRead(inputPin); // add the reading to the total: total= total + readings[index]; // advance to the next position in the array: index = index + 1; // if we're at the end of the array... if (index >= numReadings) // ...wrap around to the beginning: index = 0; // calculate the average: average = total / numReadings; // send it to the computer as ASCII digits delay(1); // delay in between reads for stability return average; }
And here is the output serial monitor.
Initilisation Complete... Triggered at: 68177 Waiting... Trigger Ready... Triggered at: 72412 Waiting... Trigger Ready...
Horiba U-52 Multiparameter Meter, 6-ft (2-m) cable
Horiba U-52 Multiparameter Meter, 6-ft (2-m) cable These handheld, waterproof meters feature a large 3-1/2" (8.9 cm), easy-to-read LCD with backlighting for use in dark and low-light conditions. Multiple parameters can be measured and displayed at the same time. USB/probe connectivity and battery power are also indicated via the display. Variable contrast allows you to adjust for extreme ambient light conditions. Meters are designed for one-handed operation. Probes are attached via a quick-connect connector allowing for fast setup. Patented auto-calibration feature provides hassle-free meter setup. Turbidity sensor offers better accuracy than most other conventional water quality meters. Polarographic DO sensor features improved stability, fast response, and easy maintenance. Auto-hold function freezes average data values providing more time to verify or transcribe data. Up to 10,000 data sets can be stored and later transferred to a PC via a built-in USB connection. Units of measure are user selectable which helps you save time.