How to setup Laser module with Arduino

The laser light has always been a fascination for doing geeky things. L.A.S.E.R stands light amplification by stimulated emission of radiation. A laser differs from other sources of light in that it emits light coherently. They are used in applications such as  laser cutting , lithography,  optical disk drives, laser printers, barcode scanners, DNA sequencing instruments, fiber-optic and free-space optical communication, laser surgery and skin treatments; cutting and welding materials.

Today we are going see how to setup laser module with Arduino. The Laser module which comes as a part of the 45 in 1 sensor kit.

You can buy it from the following link

https://www.banggood.com/Geekcreit-45-In-1-Sensor-Module-Board-Kit-Upgrade-Version-For-Arduino-p-1137050.html?p=W214159476515201703B

Connection:

The breakout board consist of three pins S, X (noname), and – (GND). The S pin should be connected to a GPIO pin and – should be connected to GND. In the below setup the S pin is connected to the GPIO pin.

Code:

void setup () {
pinMode (13, OUTPUT);
}
void loop () {
digitalWrite (13, HIGH); // turn on  the laser head
delay (1000); // delay one second
digitalWrite (13, LOW); // turn off the laser head
delay (1000); // delay one second
}

Now lets try to make a fading effect to the Laser light by using PWM. For that I connected the S pin to the Pin 9 and the circuit looks like the picture below.


/*
Fading

This example shows how to fade an LED using the analogWrite() function.

The circuit:
* LED attached from digital pin 9 to ground.

Created 1 Nov 2008
By David A. Mellis
modified 30 Aug 2011
By Tom Igoe

http://www.arduino.cc/en/Tutorial/Fading

This example code is in the public domain.

*/

 

int ledPin = 9; // LED connected to digital pin 9

void setup() {
// nothing happens in setup
}

void loop() {
// fade in from min to max in increments of 5 points:
for (int fadeValue = 0 ; fadeValue <= 255; fadeValue += 5) { // sets the value (range from 0 to 255): analogWrite(ledPin, fadeValue); // wait for 30 milliseconds to see the dimming effect delay(30); } // fade out from max to min in increments of 5 points: for (int fadeValue = 255 ; fadeValue >= 0; fadeValue -= 5) {
// sets the value (range from 0 to 255):
analogWrite(ledPin, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
}

And the after flashing the code you can enjoy the cool laser effects it produces.

3 thoughts on “How to setup Laser module with Arduino

Leave a Reply

Your email address will not be published. Required fields are marked *