Keyes KY-008 Laser Transmitter Demystified

25,754

34

16

Hi, I'm Brad. My interests spread over a large area and I tend to get carried away when something...

Intro: 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

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

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

3 People Made This Project!

Recommendations

  • Audio Contest 2018

    Audio Contest 2018
  • Optics Contest

    Optics Contest
  • Electronics Tips & Tricks Challenge

    Electronics Tips & Tricks Challenge

16 Discussions

0
None
AissaniA

10 months ago

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.

0
None
micahnightwolf

1 year ago

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.

0
None
krbonne

1 year ago

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?

1 reply
0
None
CesarV44

1 year ago

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.

1 reply
0
None
gr8ytCesarV44

Reply 1 year ago

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.

0
None
diy_bloke

1 year ago

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.

0
None
lhoril

2 years ago

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?

1 reply
0
None
gr8ytlhoril

Reply 2 years ago

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

0
None
kooth

2 years ago

Cool! This is useful! Thanks for sharing!

1 reply
0
None
gr8ytkooth

Reply 2 years ago

Thank you!

0
None
gr8yt

2 years ago

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.

0
None
Eisad

2 years ago

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

3 replies
0
None
gr8ytEisad

Reply 2 years ago

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.

0
None
gr8ytgr8yt

Reply 2 years ago

and it's fixed, thanks again

0
None
FunktioniertEisad

Reply 2 years ago

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