Introduction: Keyes KY-008 Laser Transmitter Demystified

Picture of Keyes KY-008 Laser Transmitter Demystified

I picked up a Keyes KY-008 Laser Transmitter from ICStation. I just went to play with it and found out there's a lot of confusion out there about this particular module. The fact that it appears to be impossible to locate an actual datasheet or any kind of official specifications document for it doesn't help matters any. Neither does the fact that it appears the circuit board is mislabeled.

This module has three pins. Reference the second picture above and the pins are labeled (from left to right), pin1 = S, pin2 (center) = good question/not labeled, pin3 = - (minus sign).

From what I've been able to determine the pins should be labeled;

Pin1 = Vdc

Pin2 = Ref

Pin3 = GND

I found a lot of comments about Pin2 (the center pin) not being connected to anything. That may be true on different models or older models perhaps, but on mine Pin2 is outputting the exact same voltage that's coming into the module. Off the top of my head I can see two good uses for that type of output; 1. You could use it to monitor the incoming power supply and adjust it automatically based on the output voltage. 2. You could also monitor that pin and trip a warning or alarm when that pin drops to zero (as in someone cut the power supply) or when the voltage drops below an acceptable level for your application.

Long story short, this module works and provides an option to monitor the modules power supply.

So let's set it up to work with your Arduino and make a bright red dot appear on the ceiling.

Do me a favor and click that NEXT button over there for me...

Step 1: Setup Instructions

Picture of Setup Instructions

Items you will need: (not much)

1. your Arduino

2. one (1) Keyes KY-008 Laser Transmitter Module (available at ICStation and just about everywhere else)

3. your breadboard and jumper wires (no breadboard? - go buy one you cheap... - they really do make life a whole lot easier when you're playing with this stuff)

Wiring Setup: (not much to do here either)

(always remember to disconnect any and all power supplies prior to setting things up)

1. connect pin 2 from Arduino to Vdc (sorry, to "S") on the module

2. connect GND from Arduino to - on module

3. and optionally connect the modules center pin to A5 on your Arduino (one of the attached sketchs will output the voltage being monitored on the center pin of the module to Arduino's serial monitor)

That appears to be all we need to set this up. Could you hit that Next button again for me please...

Step 2: Code

Picture of Code

So I'm going to give you a couple of options here; the first sketch will simply turn the laser on and off. And the second sketch will do the same but we will monitor the output from the modules center pin and display the results on the Arduino serial monitor.

Both files are attached, double click one and it will automatically load into the Arduino interface for you.

Sketch 1 (KY_008_Laser_A.ino) This sketch turns the laser on and off without sending information to the serial monitor

// KY-008 Laser Transmitter Demo by Brad White 12/09/2015

int Laser = 2; // creating a variable named Laser and assigning it to digital pin 2

void setup() {

pinMode (Laser,OUTPUT); // designating pin 2 as output (we can use "Laser" instead of the pin # because we assigned "Laser" to pin 2 above)

digitalWrite(Laser,LOW); // making sure the laser is off at startup or reset

}

void loop() {

digitalWrite(Laser,HIGH); // turning the laser on

delay(250); // waiting for 1/4 of a second

digitalWrite(Laser,LOW); // turning the laser off

delay(250); // waiting for 1/4 of a second

/* That's it, the code will repeat itself (from "void loop" down) over and over until you pull the plug. You can go ahead and play with the "delay" times for faster or slower on/off speeds */

}

End of Sketch 1_____________________________________________

Sketch 2 (KY_008_Laser_B.ino) This sketch turns the laser on and off and reads the voltage coming from the modules center pin which is displayed on the serial monitor.

// KY-009 Laser Transmitter Demo by Brad White 12/09/2015

/* Don't forget to open Arduino's serial monitor to see the ouput from this sketch. The serial monitor can be opened by clicking the serial monitor icon located in the top right corner of the Arduino interface, or select TOOLS / Serial Monitor or press CTRL+SHIFT+M */

int Laser = 2; // creating a variable named Laser which is assigned to digital pin 2

int voltage = 0; // creating a variable named voltage and setting is value to zero

void setup()

{

Serial.begin(9600); // starting the USB serial interface and setting the baud rate (transmission speed) to 9600

pinMode (Laser,OUTPUT); // designating digital pin 2 for output (we can use "Laser" instead of the pin # because we assigned pin 2 to Laser above)

digitalWrite(Laser,LOW); // just making sure the laser is 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 "); //sending that sentence to the serial monitor

Serial.println(voltage1); // adding the value in voltage1 to the end of the sentence above and starting a new line on the monitor

Serial.println(); // adding a blank line for readability

delay(1000); // waiting for one second before continuing sketch

digitalWrite(Laser,LOW); // turning the laser off

voltage = analogRead(A0); // reading the voltage on A0 and storing the value received in "voltage"

float voltage2 = voltage * (5.0 / 1023.0); // transforming the value stored in "voltage" to readable information

Serial.print("the laser is OFF and the voltage on the center pin is "); // sending that sentence to the serial monitor

Serial.println(voltage2); // adding the value in voltage2 to the end of the sentence above and starting a new line on the monitor

Serial.println(); // adding a blank line for readability

delay(1000); // waiting for one second before continuing sketch

/* You can play with a couple of things with this sketch 1. you can play with the "delay" times, turning the laser on and off faster or slower 2. place a resistor in-line with the power to the module resulting in different voltages displaying on the serial monitor. */

}

End of Sketch 2_____________________________________________

Have fun! And as always please do not be shy about telling me about any errors or omissions you notice in this Instructable. I'd much rather correct it than let it mess someone up.

Step 3: Specifications (what Little I Could Find)

Supply Voltage: 5Vdc max

Power Consumption: 30mA @ 5Vdc

wavelength: 650nm (red)

Pin Outs: Vdc, Ref, GND (Note: Vdc has "S" printed on the board beside the pin)

Depth: 8mm

Size: 1.8cm x 1.4cm

Comments

AissaniA (author)2017-12-06

S to +5v and - to power return of any power supply and it works without arduino. the medal pin is actualy connected to S pin through a 10k resistor and can be connected to ground as a pull-down resistor.

andystechgarage made it! (author)2017-12-03

Quick and easy project with the kids! Loved it and love the clear explanation of the laser transmitter.

gr8yt (author)andystechgarage2017-12-03

Thanks, glad it helped.

micahnightwolf (author)2017-03-06

I remember back in middle school we used an analog laser transmitter and a receiving device that was based off of either a solar panel or an array of LDRs (CdS cells) but I'm not sure which. Regardless, we managed to transmit audio from one end of the building to the other using a series of mirrors and 1 compact disc (because we needed an extra mirror. Reflective CD to the rescue! Props to the kid who held it so steadily too.) Data reception with this device is fairly easy if you have either a fiber optic connection or really good aim. And either an LDR or a phototransistor.

krbonne (author)2017-01-02

Hi,
Has somebody managed to use this device for communication?
I have been interesting in over-the-air light communication (see here http://modulatedlight.org/optical_comms/optical_in... ) and I am looking at ways to learn more about it. Although LEDs are probably better suited then lasers for this, the KY008 looks like an interested device to play around with.

Has anybody tried switching the laser on and off? How fast can the laser switch?

Also, as 5 mW of power is probably quite a bit of overkill, I am actually interested in lowering the power of the laser? Perhaps, with a lower voltage or by limiting the current, it might be possible to reduce the output to (say) 1 mW or so.

Anybody an experience with this?

krbonne (author)krbonne2017-01-02

Sorry, ... typo in the URL:
http://modulatedlight.org/optical_comms/optical_in...
(remove the ')' at the end of the URL in the original post)

CesarV44 (author)2016-11-26

I've been searching for a tutorial on this matter for about two days. I tried to use the blink sketch from arduino but didn't work, anyways ... thanks a lot for posting this tutorial (I'm new to arduino ... I just ordered a book on how to code with arduino) I'm greatly thankful ... I'll recommend this post.

gr8yt (author)CesarV442016-11-27

Thanks for the note. You should have nothing but fun playing around with this stuff. Feel free to hit me up anytime you need something. I'm not an "expert" by any means, but I do like to figure this stuff out and enjoy helping when I can.

diy_bloke (author)2016-10-19

I have struggled too with the correct use of these pins. Add to that that the silkscreen was probably wrong as well I think I ended up with he + on the - and the - on the S.

theoriginalrage made it! (author)2016-03-26

Your post inspired me to get out my laser and play around. In the picture it is hooked up to the Uno on the bottom right, flashing S.O.S. at an LDR that is connected to the Uno on the left, which turns on and off the blue LED based on the LDR values.

gr8yt (author)theoriginalrage2016-03-26

That is too cool. And thanks for the note, I appreciate knowing someone reads these things. :-)

lhoril (author)2015-12-15

very cool are there any other places where I can get the laser.

Or a laser that's a higher class, so I can burn stuff, or in different colors?

gr8yt (author)lhoril2015-12-16

there are to many places where you can purchase this stuff to mention here , a search for "electronic components" will get you started though

kooth (author)2015-12-11

Cool! This is useful! Thanks for sharing!

gr8yt (author)kooth2015-12-12

Thank you!

gr8yt (author)2015-12-09

Oops, cleaned up the code also. The code written in the Instructable that is, darn cut & paste. The code in the attached files is fine.

Eisad (author)2015-12-09

Donot try this project its great but the connections are wrong he has connected pin2 directly to ground.

gr8yt (author)Eisad2015-12-09

Thanks, I see the issue. Actually Pin 2 is connected correctly, it's the ground from the module that's wrong, it's going to positive on the breadboard instead of ground. Will fix right away, thanks for pointing that out.

gr8yt (author)gr8yt2015-12-09

and it's fixed, thanks again

Funktioniert (author)Eisad2015-12-09

no only the Lasers ground is connected to the wrong line on the Board chematic. can happen :D

About This Instructable

17,943views

32favorites

License:

Bio: Hi, I'm Brad. My interests spread over a large area and I tend to get carried away when something new peaks my interest. I ... More »
More by gr8yt:D2-3 Tracking & Obstacle Avoidance Smart Car DIY KitLED Cycle Light ReviewSimple Serial Converter Makes Pro-Mini Programming Easy
Add instructable to: