This is a diffused reflection laser sensor that has an integrated IR transmitter and a receiver. This sensor using light that transmit by the Laser and receive by the Infrared since the laser adopts modulation processing technology, the receiving tube can only receive the reflected light in the same frequency. Laser Sensor can detect obstacles at 0.8m (typ), 1.5m (max) the sensor has an oscillating tube that can generate a shock-wave in a frequency of 180 KHz. This sensor can be used to obstacle detection, counter devices at the pipeline, robotics, and smarts car, etc.
Required Component
- Arduino Microcontrollers, Teensy, ESP8266, STM32F10X, NUCLEO_401RE, NUCLEO_F030R8, NUCLEO_F103RB, NUCLEO_F302R8, NUCLEO_F411RE, ATMEGA328 16/12, ATMEGA32u4 16/8/ MHz, ESP8266, ATMEGA250 16 MHz, ATSAM3x8E, ATSAM21D, ATTINY85 16/8 MHz (Note: The Diagram below is using NANO. If your using other MCU please refer to the respective pin-outs diagram)
- Laser Sensor Module
- Jumper Wire
- Solder Less Bread Board
Wiring Diagram
Sketch Code
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 |
/* Note Sensor does not support distance measuring, does not support PWM, Wavelenght 650nm, identify modulated visible light (650~950nm) */ int sensor=2; int ledOut=13; void setup() { pinMode(sensor,INPUT); Serial.begin(9600); Serial.println("14CORE | Laser Object Detection"); Serial.println("-------------------------------") } void loop() { if(digitalRead(sensor)==LOW) { Serial.println("No object has been detected... "); digitalWrite(ledOut, 0); } else { Serial.println("Object has been detected... "); digitalWrite(ledOut, 1); } delay(500); } |
Source Code for STM32, NUCLEO
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 |
#include "mbed.h" // Hyperterminal configuration baud rate 9600, 8bit data, no parity // Serial pc(SERIAL_TX, SERIAL_RX); DigitalIn sensor(D2); DigitalOut ledOut(LED1); int main() { pc.printf("14CORE | ST NUCLEO TEST CODE") pc.printf("\r\ Reading Laser Sensor !\r\n"); while(1) { if(sensor == 1) { pc.printf("No object detected... !\r\n"); ledOut = 0; } else { pc.printf("Object has been detected...\r\n"); ledOut = 1; } wait(0.5); } } |
Wiring the Diffused Reflection Laser Sensor with Microcontroller