keyestudio
Share your creative ideas with us here
By ran | 02 January 2025 | 0 Comments

HOW to Use Laser Sensor on Raspberry Pi

Description

Lasers are widely used to cut, weld, surface treat, and more on specific materials. The energy of the laser is very high. The toy laser pointer may cause glare to the human eye, and it may cause retinal damage for a long time. my country also prohibits the use of laser to illuminate the aircraft.

Working Principle

The laser head sensor module is mainly composed of a laser head with a light-emitting die, a condenser lens, and a copper adjustable sleeve. We can see the circuit schematic diagram of this module which is very similar to the LED we have learned. They are all driven by triodes. A high-level digital signal is directly input at the signal end, then the sensor will start to work; if inputting low levels, the sensor won’t work.

Components

wps97

wps98

wps88

ESP32 Board*1

ESP32 Expansion Board*1

Keyestudio DIY Laser Module*1

image-20230602113648311

wps100

 

3P Dupont Wire*1

Micro USB Cable*1

 

Connection Diagram

Test Code

//*************************************************************************************
/*
 * Filename    : Laser sensor
 * Description : Laser light flashing
 * Auther      : http://www.keyestudio.com
*/
int laserPin = 0; //Define the laser pin as GPIO 0
void setup() {
  pinMode(laserPin, OUTPUT);//Define laser pin as output mode
}

void loop() {
  digitalWrite(laserPin, HIGH); //Open the laser
  delay(2000);  //Delay 2 seconds
  digitalWrite(laserPin, LOW); //Shut down the laser
  delay(2000);  //Delay 2 seconds
}
//*************************************************************************************

Test Result

Connect the wires according to the experimental wiring diagram, compile and upload the code to the ESP32. After uploading successfully,we will use a USB cable to power on,we will see that the laser module will emit red laser signals for 2 seconds and stop emitting signals for 2 seconds on a cycle.

Leave a Reply

Your email address will not be published.Required fields are marked. *
Name
E-mail
Content
Verification code