Site Overlay

Laser Modules with Arduino

The perfect project for any beginner featuring a simple-to-program yet powerful interfacing of Laser modules with Arduino. We’ll learn programming and use of Laser modules with Arduino for several projects.

Connection of Laser module with Arduino

Story

Before starting the project…

This laser module can be programmed and integrated with an Arduino board to be used with a variety of real-life applications. The code, on the other hand, is super simple and easy to understand as it is only 11 lines long. Basic applications for laser modules with Arduino can varied as emergency/safety lights, modes of communications, alert systems, laser pointers, etc.. The parts you will be needing for this project includes:​-

  • 1 KY-008 Laser Module​
  • 1 Arduino Uno​
  • 2 Jumper Wires (Male to Female)​​
  • 1 USB Data Cable (depends on the Arduino)

Mounting the circuit

Connection of KY-008 Laser Module​ with Arduino
Proteus of Laser module with Arduino UNO

The hardware setup is easy with just three simple connections including PWM, Power and Ground. Firstly, make sure that you unplug all power sources to your Arduino. Now, take one of the jumper wire and connect GND on your Arduino to GND on the KY-008 laser module as indicated by the (-) sign. Then, connect a jumper wire from D10 (digital pin 10) on your Arduino to the signal pin on your laser module as indicated by the (+S) sign. That’s it for the mounting of the circuit.

About the Code

The code for laser module with Arduino consists of 11 lines that includes all the functions and strings. It starts off by declaring a variable called ​laserPin (or any you like) for digital pin 10 (D10). Then, move straight onto our ​void setup​ where we set the pin we declared as an OUTPUT pin that will send information out to laser module. After that move to ​void loop​ section which composes of four main lines to the code. In the void loop​, we start by setting the pin to HIGH that turns the laser on, then have a delay for 100 milliseconds before turning the laser off, followed by delaying it by another 100 milliseconds. Since this is a loop, the whole void loop​ section repeats itself over and over again until the power is cut off. That’s it for this simple project. 

Code

int laserPin = 10; 
void setup () {
pinMode(laserPin, OUTPUT);
}
void loop () {
digitalWrite(laserPin, HIGH);
delay(100);
digitalWrite(laserPin, LOW);
delay(100);
}

Leave a Reply

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

Copyright © 2019 DIY Projects Arduino Crafts. All Rights Reserved. | Foodoholic by Catch Themes