hi welcome to an Arduino step-by-step course by Robojax if you found this tutorial helpful please
thumb up and also click on the subscribe on the right side in the lower corner
I really appreciate it this is the reach switch module for Arduino actual read switch is this one
this will establish a low current connection when this is get closer to magnetic field or a magnet
and it is being used extensively in robotics and manufacturing and other applications
whenever an object or something that gets closer to this you can turn on for example
movement of objects or a robotic arm or whatever application that you might think of you can attach
a tiny magnet or electromagnet to another piece or another object when it gets to the proximity
of this this will detect the proximity of the object and the signal will send to the control
system that you can turn on or something turn off based on what is detected we have
three wires here vcc this will be connected to five volts and there is a middle pin this is
connected to the ground that is like ground symbol and data out or digital out that's the output this
will not have different values of voltages digital either it will be 0 or it will be five volts
and there is an operational amplifier that will do the task of detecting and sending
either high or low the sensitivity of this not how sensitive it is up to what magnetic field
can be set by this variable resistor or potentiometer you can set it with the screwdriver
here is the wiring for the re-switch module from the right vcc is connected to five volts
of Arduino the middle pin ground have been connected to the ground using this grey wire
and this pink wire from the left from digital out have been connected to pin two
and here is the wiring on the module the white from the right side have
been connected to five volts of Arduino the middle one gray have been connected to the
ground of Arduino and the last pin using a pink wire have been connected to pin two of Arduino
now let me explain the wiring we define pin two
as a read n pin that is the read output will be connected to this as an input and Arduino
and then we define pin eight for relay pin where you can connect your relay turn on a light
an alarm or any other device that you want to take some other action
and on time is 200 millisecond at the moment we will change it this is a time that when
it detects something it wait for this amount of time because if you do not have a specific
amount of time if the time is very small it will fluctuate it will turn on and off continuously
and it will not be a good result for that reason we have to change this at least for reasonable
time more than half a second or longer and then off time is the amount of time that
when it goes off it waits until it goes for the next reason the same thing for this one
inside the setup we initialize the serial monitor so we can see the result of connection on this
connection for real application you will turn this off you don't need it and then using pin mode
a read pin is defined as an input using pin mode relay pin have been defined as an output where you
can connect your relay or buzzer this line will just print the text for information on the screen
at the beginning inside the loop we start reading the pin two using digital read because the signal
we are reading is a digital and we compare it using this two equal sign to see if it is low
when the wreath switch is on it sends low signal at the output so at pin 2 we should read
low when the research is on and if it is on then we take this action this is the area from here to
here you put your action I put this treeline so you can change this to whatever you are pleased
with I’m printing switch on using serial monitor and using digitalwrite we are sending relay pin
a low signal because the majority of the release that we have used in this course are low trigger
so the relay will be on otherwise if you are connecting it to other devices set this to high
and then we wait for this much amount of time that we set above lay next reading otherwise
if the research is not on the signal is not detected then we take this action
we send the relay high which means turn it off and then we print this text switch off
and we wait for this amount of time that we said above and the loop continues like that
now here is a demonstration the read switch have been connected it's powered up the light
the slide is on and also the serial monitor is showing switch off switch off continuously
and I have here this is for picking up screws and other stuff this is just magnet
I’m using this to turn this on and off once the reach switch is on you will see that the led
will turn on and also we will see the signal here so let me get this closer now the reach
switch is on and as you can see it shows switch on and if I get it away from it will turn off
and
we can set the sensitivity for example at this
point it can work and let's put it further and try it
right now it is detecting let's go away
you see it doesn't work so it's always on I have to turn it off
it has been the sensitivity have been reduced significantly and
the pull of the magnet will determine how sensitive the reaction will be so you have
to play with your magnet rotating at a different angle to get the best result
you see and I put it at that angle it has one type of sensitivity
and as you can see it is being affected even there in this side
only in this area it can be affected but not in here not in front of it so magnetic field is
more strong and this magnetic field goes like this and like this at the middle it's weak so
in both sides we see very strong field and the middle we see weaker and here we see stronger
now I’m trying to control a buzzer instead of relay the longer pin on this side is
the positive and the negative is on that side the longer pin also has this positive
sign and using the white wire I’ve connected it to pin 8 of Arduino and the ground on this side
have been connected with a blue line to the ground of Arduino now I’m getting closer the magnet
as you can see the light is on a switch on is on the serial monitor and also the buzzer is buzzing
please make sure to subscribe by clicking the subscribe button in here thank you thank you
for watching tutorial from Robojax if you learned something and found this useful
please thumb up as this will help my video in the search algorithm of YouTube
if you have comment or question please post it at the comment section below
I try to answer and reply and don't forget subscribe so you get updates on my upcoming videos
you