Another Arduino Laser Tripwire
by Jonathan Robson in Circuits > Arduino
59766 Views, 128 Favorites, 0 Comments
Another Arduino Laser Tripwire
This is my version of login258's laser tripwire at https://www.instructables.com/id/Arduino_Laser_Tripwire/
I've made a couple of modifications: the laser is now independent from the Arduino so that it can be placed anywhere in the room and I've changed the LED to a buzzer.
LASERS ARE DANGEROUS AND CAN DAMAGE THE EYES. IF CHILDREN ARE USING THIS INSTRUCTABLE ENSURE THEY ARE SUPERVISED BY A RESPONSIBLE ADULT AT ALL TIMES.
I've made a couple of modifications: the laser is now independent from the Arduino so that it can be placed anywhere in the room and I've changed the LED to a buzzer.
LASERS ARE DANGEROUS AND CAN DAMAGE THE EYES. IF CHILDREN ARE USING THIS INSTRUCTABLE ENSURE THEY ARE SUPERVISED BY A RESPONSIBLE ADULT AT ALL TIMES.
Parts
You will need:
Laser emiter, 3v battery and on/off switch OR Laser pointer and electrical tape
Arduino
Photocell (a big one because it makes an easier target)
2 10k resistors
peizo buzzer
Battery to power the arduino with a jack
breafboard
Various short jumpers
Elastic bands
Blu-tac
Bored kids
Wet sunday afternoon
Laser emiter, 3v battery and on/off switch OR Laser pointer and electrical tape
Arduino
Photocell (a big one because it makes an easier target)
2 10k resistors
peizo buzzer
Battery to power the arduino with a jack
breafboard
Various short jumpers
Elastic bands
Blu-tac
Bored kids
Wet sunday afternoon
Build the Circuit
Connect the peizo's positive wire to pin 11 via a 10k resistor and ground wire to ground on the breadboard.
Connect one leg of the photocell to the 5v pin on the arduino.
Connect the other leg to analog pin 0 AND to ground on the breadboard via the second 10k resitor.
Connect ground on the breadboard to ground on the arduino.
Plug the battery (I used 12v because that was what was to hand) into the arduino power jack when you want to use it away fronm the computer but to get it up and running it can take power through the USB for now.
Strap it all together with an elastic band.
If using a laser emitter wire it to a 3v battery pack and add lots of blu-tac to make aiming it easier later on.
Connect one leg of the photocell to the 5v pin on the arduino.
Connect the other leg to analog pin 0 AND to ground on the breadboard via the second 10k resitor.
Connect ground on the breadboard to ground on the arduino.
Plug the battery (I used 12v because that was what was to hand) into the arduino power jack when you want to use it away fronm the computer but to get it up and running it can take power through the USB for now.
Strap it all together with an elastic band.
If using a laser emitter wire it to a 3v battery pack and add lots of blu-tac to make aiming it easier later on.
Calibration
Photocells differ so you need to calibrate yours to your laser. Run the following sketch from Login258 or use the one on the arduino website at http://arduino.cc/en/Tutorial/Calibration
void setup() {
pinMode(4, OUTPUT);
Serial.begin(9600);
}
void loop(){
digitalWrite(4, HIGH);
Serial.println(analogRead(0));
}
With the sketch running press Serial Monitor on the arduino window and make a note of the numbers that appear in the bottom of the window with the laser on the photocell and when it is off (ambient light).
void setup() {
pinMode(4, OUTPUT);
Serial.begin(9600);
}
void loop(){
digitalWrite(4, HIGH);
Serial.println(analogRead(0));
}
With the sketch running press Serial Monitor on the arduino window and make a note of the numbers that appear in the bottom of the window with the laser on the photocell and when it is off (ambient light).
The Code
Upload the following sketch but adjust the value in the "if" statement to suit your photocell. Pick a number a bit above the ambient light number. This may need tweaking later, or, just pull a curtain or shrpud the photocell to lower the ambient light in the room.
/*
int buzzPin = 11; // buzzer connected to digital pin 11
void setup() {
pinMode(buzzPin, OUTPUT); // sets the digital pin as output
}
void loop(){
if(analogRead(0) < 850){ // this number depends on calibration of the photocell
digitalWrite(buzzPin, HIGH); // turns buzzer on
delay(1000); // waits for 1 second
digitalWrite(buzzPin, LOW); // turns buzzer off
} else{
digitalWrite(buzzPin, LOW);
}
}
/*
- Jonathan Robson Feb 09.
- Laser tripwire activates a buzzer. adapted from
- https://www.instructables.com/id/Arduino_Laser_Tripwire/
int buzzPin = 11; // buzzer connected to digital pin 11
void setup() {
pinMode(buzzPin, OUTPUT); // sets the digital pin as output
}
void loop(){
if(analogRead(0) < 850){ // this number depends on calibration of the photocell
digitalWrite(buzzPin, HIGH); // turns buzzer on
delay(1000); // waits for 1 second
digitalWrite(buzzPin, LOW); // turns buzzer off
} else{
digitalWrite(buzzPin, LOW);
}
}