Lesson 7 Laser Transmitter

Share for us
Share on facebook
Share on twitter
Share on pinterest
Share on whatsapp


Laser is widely used in medical treatment, military, and other fields due to its good directivity and energy concentration. The Laser Transmitter module (as shown below), as the name suggests, is a one that can emit laser.


– 1 * Raspberry Pi

– 1 * Network cable (or USB wireless network adapter)

– 1 * Laser-transmitter module

– Several jumper wires

Experimental Principle

A laser is a device that emits light through a process of optical amplification based on the stimulated emission of electromagnetic radiation. Lasers differ from other sources of light because they emit light coherently.

Spatial coherence allows a laser to be focused to a tight spot, enabling applications like laser cutting and lithography, and a laser beam to stay narrow over long distances (collimation), enabling applications such as laser pointer. Lasers can also have high temporal coherence which allows them to have a very narrow spectrum, i.e., they only emit a single color of light. And its temporal coherence can be used to produce pulses of light—as short as a femtosecond.

Experimental Procedures

Step 1: Build the circuit

                        Raspberry Pi                              Laser-transmitter

                             GPIO0————————————- S

                              3.3V————————————— +5v

                             GND ————————————– GND

Step 2: Edit and save the code (see path/Rpi_SensorKit_code/09_laser/laser.c)

Step 3: Compile

              gcc  laser.c  -lwiringPi

Step 4: Run


Here you can see the laser blinking constantly.

Note: DO NOT look directly at the laser head. It can cause great harm to your eyes.


#include <wiringPi.h>
#include <stdio.h>

#define LaserPin    0

int main(void)
	if(wiringPiSetup() == -1){ //when initialize wiring failed,print messageto screen
		printf("setup wiringPi failed !");
		return 1; 
	//printf("linker LedPin : GPIO %d(wiringPi pin)\n",LedPin); //when initialize wiring successfully,print message to screen

	pinMode(LaserPin, OUTPUT);

		digitalWrite(LaserPin, HIGH);
		digitalWrite(LaserPin, LOW);

	return 0;

Python Code

#!/usr/bin/env python
import RPi.GPIO as GPIO
import time

LedPin = 11    # pin11

def setup():
	GPIO.setmode(GPIO.BOARD)       # Numbers GPIOs by physical location
	GPIO.setup(LedPin, GPIO.OUT)   # Set LedPin's mode is output
	GPIO.output(LedPin, GPIO.HIGH) # Set LedPin high(+3.3V) to off led

def loop():
	while True:
		print '...led on'
		GPIO.output(LedPin, GPIO.HIGH)  # led on
		print 'led off...'
		GPIO.output(LedPin, GPIO.LOW) # led off

def destroy():
	GPIO.output(LedPin, GPIO.LOW)     # led off
	GPIO.cleanup()                     # Release resource

if __name__ == '__main__':     # Program start from here
	except KeyboardInterrupt:  # When 'Ctrl+C' is pressed, the child program destroy() will be  executed.