My name is Ahmad Shamshiri. I am presenting this tutorial from Canada.
Hi, welcome to another video tutorial from Robojax. in this video we are
going to see how we can use this E18-D80NK obstacle avoidance infrared sensor.
so this is the sensor I've connected it to a buzze.r when it
detects an obstacle up to 80 centimeter it can trigger a switch. so you can use
this to in your smart car or any robotic application that so detect an obstacle
and turn on a motor, relay, switch whatever you want to do w with this. so you can get the
code for this project by clicking at the link at the description which will take
you to www.Robojax.com/learn/arduino
Hardware exlained
this is the module the E18-D80NK it has two lenses here one is for
transmitter one is for receiver does not matter for us. then we have a
ring here in case if you are installing it and something that you drill so you
can drill and then put this and tighten it from both sides so it can stay in place.
the wiring is very good in a very strong connectivity so we have one screw
for adjusting the sensitivity which I'm gonna show you how you set this in
sensitivity. and this is the light when it an obstacle, the light will turn ON>
the diameter is seventeen point six millimeter so with the rank
the says twenty three point two millimeter so the length is forty nine
point five millimeter. this cable is about 60cm. depending on
where you get it the one that I have is 60 centimeter wire.
Wiring explained
the device has three wires here I've connected the brown to five volts this
is connected to five volts and then there is another wire which is blue
connected to the ground and black which is a signal out connected to pin 2.
I have connected pin 9 to the buzzer here to the positive of the buzzer and
then the negative of the buzzer is connected to the ground so to make clear
if I hear something this is the one that I'm using now as you can see blue is
ground VCC is a brown one and a signal is a black if you get another color
which is red that will be the VCC ground is black and yellow is signal. this is a
very good way to do it I don't know why these guys are doing it with these guys
have broken the convention. but this is how it is so and it should work. and as
you can see here they mentioned 7.4kΩ to 10kΩ
so you can put 1kΩ to 20kΩ ohm no problem if you're not using
pull-up resistors(inside code). for any reason you can put that and then connect it.
well here is again the diagram if you're using pull-up resistor so this is how
you do. this is a black which goes out make sure that the same pin that goes
out connected with a 10kΩ resistor to 5 volt DC then this will
be an independent pin and it will work if you connect it to pin 2 or Arduino without the
pull-up resistor (inside code) but I just avoid this extra wire and I just used in here
and here I set INPUT_PULLUP by saying that I eliminated this resistor but it's
up to you. so if you want to use a resistor this is how it's done.
Code explained
let me explain the code here the first thing that we define is pin 2 for the
input here and I call it sensor and then I define pin 9 for action. so this is the pin where
black wire will be connected to pin 2. so after that so this is the setup inside
the setup we just initialized the serial dot begin with 9600 baud which is used
in this screen( click on Tools->Serial monitor) and then we set that sensor which is pin 2 as if I typ
here 2. INPUT_PULLUP this is very important otherwise you have to put
another resistor in on your order board to make it work. so this is very
important that you put input underscore pull-up so when you put this pull-up
it's as if that's pin 2 is connected with a pull-up resistor to the positive.
if you're using pull a processor so this is how you do this as a black which
goes out make sure that the same pin that goes out connected with a 10 kilo
ohm resistor to 5 volt DC then this will be an independent pin and it will work
if you connect it to pin 2 without the pull-up resistor but I just avoid this
extra resistor. that's why are important and the action this is as if I type 9 that 9 is there
so where they are saying 9 as an output so this is the action pin. inside the
loop we say sensors digitalRead from sensor and the result will be restored
and L and we say if L is equal equal == 0 this means because you remember we set
pull-up resistor is connected to 5 volts so normally when there is nothing it
will be 5 volts so when it is zero actually it detects something. so we say
if L equal equal ==0 zero which means value of L is 0, 0 means also LOW then we print
this text serial dot printer we say "obstacle detected" that this is a
text that you see here. and and then also we say action HIGH so
this set pin 9 that I've connected the buzzers that you hear the sound. so
this is a place that you can do whatever you want you can control a server to do
something you can switch a motor change the direction of a motor stop it you can
turn on a relay whatever you want this is a place that you want to put your code. so either
remove this or maybe just press ENTER and then type your own code when it
detects an obstacle. then we say else so the else is when there is nothing no
obstacle is detected so it prints "All Clear" as you can see this is
all clear and also we send a pin 9 to LOW state so this is in this case it's
connected to the buzzer so the buzzer will go off and after that we wait five
hundred millisecond this is half a second but if you want this one to go
faster because when it reaches here this delay just Waits and then it goes back
to the loop and continuously this happens with the exception of this delay.
so if you want this one to go very fast make this smaller so 300 millisecond is
0.3 or 1/3 of second or if you make it
hundred millisecond would be 1/10 of a second because one second is 1000
milliseconds. or if you wanted to act slow just make the 600 700 or maybe one
second which is 1000 whatever you want. and then the loop continues like that.
Demonstration
as you can see here the sensor is running can also the code here it says
all clear I didn't want to show you this code because you just saw it so we are
just looking at this result. and you can also hear the buzzer when it makes buzz.
so for you in order to see it I just put it close to the table when I point it to
the table it says obstacle detected and when I put it up because the wall is too
far it says clear all clear so the pin 9 is
now LOW and the buzzer is not making any buzz. and interestingly I've tested this
this works up to 80 centimeter that I did and which is very true so you can
just change the sensitivity from here and then also there is an LED will go
high so let me show you yes you can see because this is too far and when it
detects the light is on so now let me change the sensitivity so to change the
sensitivity just you see that it's not detecting
I rotated right (clockwise)
if I rotate this counterclockwise it reduces the
sensitivity so you see this is about 30 centimeters
it doesn't detect so then 20 centimeter or 25 centimeter that detects now
because I turned it counterclockwise to the left. now if I rotate this clockwise
to the right then it will it it will detect almost like you know I'm just I'm
just going up this is now about 60 centimeters or more from surface so let me rotating
this clockwise
I'm going back counterclockwise and slowly clockwise so now it detects now
if I go a little low and the ticks on our obstacle now at this point it
doesn't so now let me see here's my hand okay so I hope it's
pointing so i have
so I'm just reducing the sensitivity to
reduce it and going back counterclockwise
so then you go back clockwise make sure that it gets so
a little counterclockwise so now this is not sensitive so I bring this up it
detects that now it's around 40 centimeter when I bring it down
it doesn't before the five centimeter so this is very good so far this is one of
the best one that they've seen with infrared except the SHARP sensor that measures
the distance. so this is very sensitive and the fact that this works better is
because they put a lens here. thank you for watching this fourth introduction to
e 18 d 8 0 and k obstacle avoidance answers I definitely recommend this if
you're doing robotics project this is a little large with comparing to the other
items but the quality is amazing so it works very well with the distance that
is needed for majority of the robotics the only thing that I did not have is
the speed or the reaction of this so please thumb up 👍 the video please share
it and also don't forget to subscribe to get updates of my upcoming videos.
Subtitle typed on August 29, 2020
I did my part to help you learn. Now it is your turn.
You can subscribe to my channel, thumb up 👍 the video and type a comment by saying thank you.
If you don't skip ads it will also help you .
My PayPal Account link is in the description if you want to make cash donation. Thank you