Hello, My name is Ahmad Shamshiri and I am presenting this tutorial form Canada.
welcome to another video tutorial from Robojax. in this video I'm going
to show you how we can use this laser transmitter and this laser receiver to
detect the ray of laser and turn on a buzzer or do something like this. when
the Ray shines here we detect it and we turn on something or do some action. so
this can be done in two ways one way would be that the Ray always shines and
you detect the existence of laser beam when something goes in
between and it create an obstacle, you detected or the other way
if there is an obstacle all the time let's say the door is open and if the
door opens on an object moves the Ray reaches the sensor so you put it and
align it like that so it's aligned all the time and relay blocked so when the
obstacle is removed alarm is triggered. so this can be applied in automation
robotics and many other applications. you can get the code for
this project by clicking at the link at the description below which will take
you to www.Robojax.com/learn/arduino
Hardware is explained
this is the transmitter module 5 milli watt laser here is installed and when
you connect it to 5 volts this resistor is preventing extra current so if you
wanted to connect it directly of course you can modify this module and make it
work with other voltages but this is made for 5 volts and then we have three
pins here. The middle pin is just extra it's useless not connected to anything and
then we have negative this is connected to the ground GND and then on the other side
we have s signal or positive in this video I'm connecting this to 5 volts
separate voltage but if you wanna experiment you can get the 5 volts from
Arduino 5 volts and it'll work fine so this the this module is 14.8
millimeters is the width, the length of the module is 18.8 millimeter but
if you want to calculate the so from that side to the end
so the receiver module is 23.4 millimeter and
of length in terms of width at 15.4 millimeter one thing
good about this module is that you can remove this receiver and connect wire and extend
it and put it in another location. That's very good they made it with this socket
so you can add and remove it
Code is explained
so let me explain the Arduino code here. the Pin 2 is the receiver or RX input
receiver of laser sensor when it sense it so we have assigned pin 2 for that.
pin 8 action pin which is connected to the buzzer in this
case which you can do anything you want after that so these two will be
used instead of the number two or eight so I would use detect and take action.
inside the setup() which starts from here to here we define the serial
monitor to print this text for us so we have to initialize it with the serial.begin(9600)
with 9600 baud. 9600 baud is at a rate at the bottom of the screen so this number
must match that and then we have the serial monitor print which print the top
text that you just saw and then we set the DETECT pin as input and the DETECT
means 2 so this is as if I type 2 here and then ACTION as if I type 8. So 8 as
an output that's for the action so this 3 is extra so after this we go inside
the loop() function. inside the loop() we say digitalRead(DETECT) which means
go and read the pin 2- this is as if I type 2. So the result will be stored and
the integer variable called "detected" and here we say if "detected" is equal HIGH so
when the laser beam says detected this will value will be HIGH then
we say digitalWrite(ACTION, HIGH) which sets pin 8 as HIGH so this sets the buzzer on or
whatever else you want to do and as prints the text "detected". so from here to
here this is where you remove this and put whatever you want. you can move a
servo you can send an alarm you can activate a camera to take picture or
whatever action you want so it can be here if the detected is not HIGH that
means else if it's not then action pin is set to low so the buzzer will stop as you can
see the buzzer is now not making any buzz and it says
and also prints "no laser" and after that we just wait 200 millisecond which is
1/5 often seconds so 5 times a second it just reads that after this it goes and
the loop continues
Wiring is explained
So the module here this wire goes to ground through the blue so this is
connected here the last pin is the five volts it goes to the five volts and the
middle pin is the out or the signal which is connected to pin 2. the
transmitter is connected separately to 5 volts or you can connect
the ground to the ground GND of Arduino and then
five volts to the five volts you can get from Arduino as well a buzzer is a 5V or Arduino
Here is 5 volt buzzer it has two pin. one pin is longer which is a positive also it
has been labeled at the top as 5 volts so I've connected it here on the
breadboard and from breadboard (see link for my video on how to use breadboard) this is connected to the ground I have extra
gram here and this is connected to the pin 8 where
it receives the signals and triggers the action
Project Demonstration
now here is a demonstration again with the screen here the laser is now in
here so now the laser is shining on the receiver here as you can see here we see
the word "detected" on Serial Monitor. when I go up it says no lasers no lasers but when it beams on it it
says detected and also the buzzer is buzzing so because this is very
sensitive to the laser beam even if I shine it here directly the deflection
will turn it on as you can see so keep in mind that it's the reflection will go
to that so you see in here it doesn't work because it doesn't reflect but in
in this area when it reflects it gets it if it goes a little away it doesn't work
here doesn't work and here it works because it's reflecting or directly goes on it.
Thanks for watching this was introduction to the laser receiver and
transmitter projects please thumb up 👍 the video, like it and also please subscribe
and share the video I appreciate it
Subtitle is corrected and typed by Ahmad Shamshiri on Feb 28, 2020. Please subscribe to help me make more projects like this.