logo-mobile

ROHM

ROHM
Menu
  • Arduino –
  • Raspberry Pi –
  • Trending –
  • Others –
  • About –
  • Contact –

Arduino

How To MacGyver A Laser Tripwire Using Arduino

DevicePlus Editorial Team
Published by DevicePlus Editorial Team at February 23, 2018
Categories
  • Arduino
Tags
  • Arduino
  • arduino home security system
  • arduino sensors
  • home security system

 

LASER TRIPWIRE WITH ARDUINO

Purpose
This tutorial describes how to create laser tripwire with an Arduino Uno. If you are unfamiliar with the Arduino platform please refer to the “Setting Up Arduino Tutorial.”

Overview
In this tutorial, you will learn how to set up a laser tripwire sensor and trigger an actuator, in this case an LED, upon the beam being broken. You will learn how to use an if/else loop, laser diodes, and a photoresistor.

WARNING: Lasers can be harmful to the eyes and you should never look directly into the beam.

Equipment

  1. Arduino Uno R3 – https://www.adafruit.com/product/50
  2. “DOT” Laser Module – https://www.amazon.com/gp/product/B076HKH5NV/ref=od_aui_detailpages00?ie=UTF8&psc=1
  3. 20 piece Photoresistor Set – https://www.amazon.com/gp/product/B00H4ZSGXC/ref=od_aui_detailpages00?ie=UTF8&psc=1
  4. 9V, 1A Power Adapter – https://www.adafruit.com/product/63
  5. Jumper Wires – https://www.amazon.com/GenBasic-Female-Solderless-Breadboard-Prototyping/dp/B01MS9GY7W/ref=sr_1_1_sspa?s=electronics&ie=UTF8&qid=1515705634&sr=1-1-spons&keywords=jumper+wires&psc=1
  6. USB Cable (A-to-B) – https://www.amazon.com/AmazonBasics-USB-2-0-Cable-Male/dp/B00NH11KIK
  7. Breadboard – https://www.amazon.com/Elegoo-Breadboard-Solderless-Distribution-Connecting/dp/B01EV6LJ7G/ref=sr_1_1_sspa?s=electronics&ie=UTF8&qid=1515705714&sr=1-1-spons&keywords=breadboard&psc=1

Table of Contents

  1. Circuit Design
  2. Writing the Code
    1. Pin Definitions
    2. Setup
    3. Loop
  3. Uploading and Running the Code

Procedure

1.1 Circuit Design

The circuit design for this project is fairly simple. There are 3 parts of the circuit: the laser power, the photoresistor receiver (the sensor), and the LED indicator (the actuator). Microcontrollers are typically said to receive information from the outside world through sensors and to relay information or perform actions through actuators. I am choosing to use a LED indicator as my actuator, but this could be an alarm, SMS text, or even a door lock.

I always like to make a schematic (Figure 1: Circuit Schematic) using Fritzing, an open-source schematic capture and PCB routing software. This way I always have something to reference in the future. You can download Fritzing using the following link (optional): http://fritzing.org/home/

Figure 1: Circuit Schematic

The first part of the circuit is the power for the laser diode. You can power the laser diode of the 5V pin (Red Wire). Although I want to be able to turn the laser on/off, the Digital Output pins on the Arduino do not provide enough power for my laser diode. The negative lead will go to GND (Black Wire). Make sure you don’t require a current limiting resistor for your laser diode. If you do, size appropriately.

Next, we will create our actuator (LED indicator). The purpose of the actuator is to inform us that the laser diode beam has been broken. The LED and resistor should be connected in series between Pin 9 (Light Blue Wire) and GND (Black Wire). The resistor is there to limit current through the LED and should be sized accordingly depending on your LED to prevent burning it out. Remember that the longer lead on the LED is positive and should be connected to Pin 9.

Finally, the last part of the circuit is the photoresistor (Figure 2: Photoresistor), our sensor. A photoresistor is a resistor whose values change depending on light shining on the face of the resistor. One lead should be wired to Pin 7 (Light Blue Wire) and the other lead to GND (Black Wire). The photoresistor I am using has a high resistance when light is shining on it and a low resistance when no light is present.

Figure 2: Photoresistor

2.0 Writing the Code

2.1 Pin Definitions

The first part of the code is to define the pins. This step is optional, but I chose to give the pins descriptive names so they are easy to remember and track. Also, if I ever change how the circuit is wired I only have to change the Pin Definition as opposed to changing every line of code where the pin number is mentioned.

In our circuit, the photoresistor is defined as “Pin 7” and the LED is defined as “Pin 9”.

Figure 3: Pin Definitions

2.2 Setup

In the setup part of the code, configure the LED pin as a digital output.

Figure 4: Setup Code

We also configure the photoresistor as a digital input with a pullup resistor (INPUT_PULLUP). The circuit we are creating is similar to the one below and a common electrical circuit. The pullup resistor and voltage source are internal to the MCU (Arduino) in this case and the “button” is our photoresistor. When the laser diode shines on the photoresistor, it has a high resistance and the pullup resistor pulls the voltage of the input to a digital high. When the beam is broken, the resistance of the photoresistor drops and the input voltage goes to digital low.

Figure 5: Pullup Resistor Input Circuit

2.3 Loop

For the repeating loop, I wrote an IF/ELSE statement that continuously polls the photoresistor digital input. IF the digital input is high, the LED output is off; ELSE the LED output is on.

Figure 6: Loop Code

3.0 Uploading and Running the Code

Figure 7: Arduino Circuit with Laser Tripwire

Upload the code to the Arduino. Make sure the Arduino is connected using the 9V Power Adapter as power over USB might not be sufficient to power both the Arduino and the laser diode. Once the program begins, the laser diode should be outputting a beam of light. If the beam is shining on the photoresistor, the LED will be off (Figure 8: Laser Tripwire). When the beam is broken, the LED lights up indicating the trip wire has been tripped (Figure 9: Tripwire Broken).

Figure 8: Laser Tripwire

Figure 9: Tripwire Broken

TIP: If your LED is not lighting up, use a multimeter to check the resistance of the photoresistor with the laser diode shining on it and with the beam broken. The photoresistor should have a value in the kilo-Ohms with the light hitting the photoresistor and the low hundreds of Ohms or lower.

Appendix: Laser Tripwire Code Text

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*       Project: Laser Tripwire Tutorial      
*       Written by: Chris Marella                
*       Date: January 24, 2018
*       Version: 1.0  
*      
  */
 
//Pin Definitions
const int photo = 7;
const int LED = 9;
 
void setup() {
  //Pin Configurations
  //Outputs
  pinMode(LED, OUTPUT);
  digitalWrite(LED, LOW);
 
  //Inputs
  pinMode(photo, INPUT_PULLUP);
 
}
 
void loop() {
  //if/else loop checks if photoresistor is high or low
  if(digitalRead(photo)==HIGH){
    digitalWrite(LED, HIGH);
  }else{
    digitalWrite(LED, LOW);
  }
 
}

DevicePlus Editorial Team
DevicePlus Editorial Team

Check us out on Social Media

  • Facebook
  • Twitter

Recommended Posts

  • DIY Arduino Home Security System using ROHM Sensor Kit Part 2 – Cayenne SetupDIY Arduino Home Security System using ROHM Sensor Kit Part 2 – Cayenne Setup
  • DIY Arduino Home Security System using ROHM Sensor Kit Part 1 – MechanicsDIY Arduino Home Security System using ROHM Sensor Kit Part 1 – Mechanics
  • Arduino Robot RF Explorer – Mechanics – Part 1Arduino Robot RF Explorer – Mechanics – Part 1
  • 3D Cases for ROHM Sensor Evaluation Kit and RohmMultiSensor Library Update3D Cases for ROHM Sensor Evaluation Kit and RohmMultiSensor Library Update
  • Arduino Sensors – ROHM Sensor Evaluation Kit OverviewArduino Sensors – ROHM Sensor Evaluation Kit Overview
  • DIY Halloween Zombie Mask using ROHM Arduino Sensor KitDIY Halloween Zombie Mask using ROHM Arduino Sensor Kit
Receive update on new postsPrivacy Policy

Recommended Tutorials

  • How to integrate an RFID module with Raspberry Pi How to integrate an RFID module with Raspberry Pi
  • How to Use the NRF24l01+ Module with Arduino How to Use the NRF24l01+ Module with Arduino
  • How to Run Arduino Sketches on Raspberry Pi How to Run Arduino Sketches on Raspberry Pi
  • Setting Up Raspberry Pi as a Home Media Server Setting Up Raspberry Pi as a Home Media Server

Recommended Trends

  • SewBot Is Revolutionizing the Clothing Manufacturing Industry SewBot Is Revolutionizing the Clothing Manufacturing Industry
  • All About The Sumo Robot Competition And Technology All About The Sumo Robot Competition And Technology
  • 5 Interesting Tips to Calculating the Forward Kinematics of a Robot 5 Interesting Tips to Calculating the Forward Kinematics of a Robot
  • Go Inside the Drones That Are Changing Food Delivery Go Inside the Drones That Are Changing Food Delivery
Menu
  • Arduino –
    Arduino Beginner’s Guide
  • Raspberry Pi –
    Raspberry Pi Beginner's Guide
  • Trending –
    Updates on New Technologies
  • Others –
    Interviews / Events / Others

Check us out on Social Media

  • Facebook
  • Twitter
  • About
  • Company
  • Privacy Policy
  • Terms of Service
  • Contact
  • Japanese
  • 简体中文
  • 繁體中文
Don’t Forget to Follow Us!
© Copyright 2016-2023. Device Plus - Powered by ROHM
© 2023 Device Plus. All Rights Reserved. Muffin group

istanbul escort istanbul escort istanbul escort