2. Laser Emitter/Detector

A laser emitter is a device that generates a beam of light and other electromagnetic radiation through a process of optical amplification. A laser detector is a passive device used to identify these types of infrared emissions. Different lasers operate at different wavelengths from ultraviolet through the visible light spectrum to infrared. The shortest wavelengths, from 10 to 400 nanometers (nm), produce ultraviolet (UV) light. Intermediate wavelengths, from 380 to 740 nm, produce visible (VIS) light from violet to red. The longest wavelengths, from 700 nm to 1 mm, produce infrared (IR) light which, like UV, is invisible to the human eye. The emitter sends a laser beam and the receiver detects the emitted beam. Any time there is an obstacle that breaks the beam of light and prevents it from reaching the receiver, an input is detected on the Raspberry Pi.

Laser Emitter:

../_images/laser-emitter-1.jpg ../_images/laser-emitter-2.jpg

Laser Detector:

../_images/laser-detector-1.jpg ../_images/laser-detector-2.jpg

2.1. Connecting the Emitter

Connect the Signal(S) to a 5V pin

Connect the ground to a ground pin

Note

We won’t be using the middle pin of the emitter

In this example:

  • Signal is connected to pin 2
  • The ground is connected to pin 6
../_images/laser-emitter.jpg

2.2. Connecting the Detector

Connect the VCC to a 3.3V pin

Connect the ground to a ground pin

Output, should be connected to a GPIO as an input

In this example:

  • VCC is connected to pin 1
  • The ground is connected to pin 6
  • Output is connected to pin 22
../_images/laser-detector.jpg

2.3. Python Program to Show Laser Detector State

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
LD=22
GPIO.setup(LD,GPIO.IN)

while True:
    if(GPIO.input(LD)== True):
        print "Laser Detected"

    else:
        print "Not Detected"
    time.sleep(1)