I was fascinated by LASERs when I first went to IIT Kanpur during my school days. Since then I have been reading / playing a lot with LASERs. My first one was a LASER trip wire and then a LASER pattern generator. It all was around 10 years back. Having recently acquired an Arduino UNO a plethora of options have opened up. I have started to learn from the beginning and this time I have the power of a microcontroller with me. !0 years back these things were hard to find and were freaking expensive and I didn’t have a sponsor 😛
Now I play around with stuff and fund my own projects. I have recently made a dice and a digital thermometer just to learn the new way of doing it.
Next was this LASER Projector (pattern generator to be precise). It involves two DC motors and L293D as a motor driver.
I customized the Motor driver circuit for speed control with Arduino PWM.
The table shows the connection details.
Two push buttons were added to control the speed of one motor. The other one rotated with a constant speed. One PWM pin was used to control the LASER as it gets too hot when switched on continuously.
The photo below shows the setup (Not very neat though)
Video
Source code
//LASER SHOW//
int motor1pin1 = 5; //define digital output pin no.
int laser = 12; //define the pin for laser output PWM.
int motor1pin2 = 6; //define digital output pin no.
int speedpin1 = 3; // define analog output pin no.
int motor2pin1 = 9; //define digital output pin no.
int motor2pin2 = 10; //define digital output pin no.
int speedpin2 = 11; // define analog output pin no.
int up = 1; // define pushbutton pin no.
int down =2; // define pushbutton pin no.
int factor =32; //define speed control variable
void setup () {
pinMode(motor1pin1,OUTPUT); //set pin 3 as output
pinMode(motor1pin2,OUTPUT); // set pin 4 as output
pinMode(motor2pin1,OUTPUT); //set pin 3 as output
pinMode(motor2pin2,OUTPUT); // set pin 4 as output
pinMode(speedpin1,OUTPUT);
pinMode(speedpin2,OUTPUT);
pinMode(laser,OUTPUT);
pinMode(up,INPUT);
pinMode(down,INPUT);
Serial.begin(9600);
}
void loop () {
analogWrite(laser,228);
analogWrite(speedpin1,32);
digitalWrite(motor1pin1,LOW);
digitalWrite(motor1pin2,HIGH);
analogWrite(speedpin2,factor
);
digitalWrite(motor2pin1,HIGH);
digitalWrite(motor2pin2,LOW);
if(digitalRead(up)==LOW)
{
factor++;
}
if(digitalRead(down)==LOW)
{
factor–;
}
Serial.println(factor);
delay(500);
}