Menu Close

Arduino – Laser Sensor

This tutorial explains how to use Laser Sensor with Arduino.

1. Introduction:

Laser sensors are used where small objects or precise positions are to be detected. They are designed as through-beam sensors, retro-reflective sensors or diffuse reflection sensors. Laser light consists of light waves of the same wave length with a fixed phase ratio (coherence).

The wavelength of laser light is 650 nm (red) with Unlimited (vacuum) range.

2. Hardware required

S.No.ItemQuantity
1.Arduino 1
2.Laser Sensor 1
3.Male to Female Jumper Wires 3

3. Circuit Diagram

Make the following connections with Arduino-

4. Programming

You may download this Arduino Sketch from here.

//Robo India tutorial on Laser Sensor
//https://www.roboindia.com/tutorials

int Laser = 2;   
int voltage = 0; 

void setup()

{
Serial.begin(9600); 
pinMode (Laser,OUTPUT); 
digitalWrite(Laser,LOW);  // set laser off at startup or reset
}

void loop() 
{
  digitalWrite(Laser,HIGH);      // turning the laser on
  voltage = analogRead(A0);                                                    //reading the voltage on A0 and storing the value received in "voltage"
  float voltage1 = voltage * (5.0 / 1023.0);                                  // transforming the value stored in "voltage" to readable information
  Serial.print("the laser is ON and the voltage on the center pin is ");      
  Serial.println(voltage1);                                                    
  Serial.println();                                                               
    delay(2000);                                                                // wait for two second 
  digitalWrite(Laser,LOW);                                                    // turning the laser off
  voltage = analogRead(A0);                                                      
  float voltage2 = voltage * (5.0 / 1023.0);                               
  Serial.print("the laser is OFF and the voltage on the center pin is ");          
  Serial.println(voltage2);                                                       
  Serial.println();                                                             
    delay(2000);                                                               // wait for two second 
}

5. Output

After uploading the code successfully, Open up the Serial Monitor. Laser beam will blink with time interval of 2 second.

If you have any query please write us at support@roboindia.com

Thanks and Regards
Content Development Team 
Robo India
https://roboindia.com

Leave a Reply