Introduction
Laser projects can build either directly on laser components or modules with lasers. When wiring a laser, the only additional component needed is a resistor. Modules come with a built-in resistor, but also take unnecessary large volume. The sketch (script) is the same in both cases.
Laser Module
The laser module KY-008 is a bit secretive, I have not been able to find a proper datasheet. But at arduinomodules.info it is stated that it requires 5 v input, thus you only need to wire directly to power and ground.
The central pin is connected to the 5v input and all it does is reveal the voltage sent to the module. it can be used for surveillance of the power supplied to the laser, and for instance sound a warning when the power is too low or has been on for a certain amount of time.
Laser component
Wiring for a 3v laser that consumes 40 mA. The information available is vague. But I put a 56 Ohm resistor as that is what is required for changing from 5v to 3v when the current is 0.04 A (40 mA), calculated here or here (with the same result).
Sketch
The sketch is the same for all of the wiring above.
// Laser, turn on/off
int laserPin = 6;
void setup ()
{
pinMode (laserPin, OUTPUT); // define the digital output
}
void loop () {
digitalWrite (laserPin, HIGH); // Turn Laser On
delay (500); // On For Half a Second
digitalWrite (laserPin, LOW); // Turn Laser Off
delay (500); // Off for half a second
}