Keyes KY-008 Laser Transmitter Demystified
by gr8yt in Circuits > Arduino
40330 Views, 41 Favorites, 0 Comments
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...
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...
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.
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