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 hi welcome to an Arduino tutorial from Robojax in this tutorial I’m going
to introduce this vti technology scs60c angle sensor to measure the angle for any purpose
that you have in robotics this is around 90 and then it can if I go this way we can go minus 90.
this is your minus 90 and it can go here to minus 180 and then rotate this so this is now
angle sensing is one of the important aspects of robotics and in many applications you constantly
need to know the position of angle of some arm or some element in your robotics and this is
very inexpensive way to do that this can display between 0 and 180 degrees and
the resolution is one degree so you cannot have zero point something degrees so with the
resolution of one degree this will work and it is from vti technology here if you search AliExpress
you can get this fcs60c they call it a tilt sensor the chip is also sold here
you can see it on amazon.com it is sold for 41 36 at different prices
so this is now for example sold for 10 where you can get it in 40 days
and this is just a module without those adjustment pins
at different prices you can get it on amazon.com even 766 dollars but these we
can get it in 60 days so don't expect that quick delivery 32 dollars for example here on eBay
for 14.25 cents plus shipping and also just the chip
now let me explain the module the module is based on vti technology's angle sensor this is scsx0c1
with a sub version of n100 effect zero and this is when you put it this way we will have always at
zero degrees so this will give you the angle and based on angle it outputs some voltage here
where we can convert it to angle and read the angle so the angle will be between 0 to 180
degrees and the output will be between some 0.45 volts to 4.5 volts we're using Arduino to display
the angle and here we have two leds that when it is absolute flat you can set this with these two
variable resistor or potentiometer so these alarms are off here at the bottom we have
l393 this is an op-amp operational amplifier very precise so this will turn these on at the specific
value so you can detect if it is flat or not and the result of this will output as d1
d out one at this pin the spin will go low when it is detecting it
and this side when this led turns on it goes to d out two this vcc will be connected to
five volts ground the spin will be connected to ground so for majority of the use is this vo
this pin we are using this one to detect the angle length of this module is 34.2 millimeters
by 21.1 millimeters by 8.4 millimeters
and here's the datasheet for vti technology s cfx0c and this one also has sub number n one
four zero quadruple zero six zero
operating supply is five volts and it consumes two milliampere
g and if you put it flat it will be zero and if you put it this way the arrow is on the surface
that will be minus g provided a data sheet if in case if you need it
now here is the wiring diagram for this sca-60c sensor from this site from vcc we are connecting
one wire to five volts and then the second pin is dr2 using purple wires to analog 2
and then v out from the middle using blue wire is connected to analog 0. this pin the green is
the ground ground is connected using a green wire to one of the ground you can connect it here or
you can connect it on the other side and then d out one using yellow wire you can connect it
to analog zero I have connected the out one to analog one and the out two to analog two and v
out or v zero to analog zero so you don't make mistake and here's the explanation of wiring
we have here vcc this is connected to five volts of Arduino and then we have the from this side
the second pin is ground ground is connected there so these two pin s will supply power and then here
at the middle v out v out is the one that you will get you the angle that's a blue blue is connected
to analog zero these two d out one and d out two this orange and this purple or connected to here
analog 1 and r2 which I’m going to demonstrate it and if you do need it you can remove this the out
2 and the out one because these are just for turning on and off some alarm if you need
now let me explain the code we are defining a constant integer pin so you put a pin that
you're using and then this is a variable that is holding the angle do not change it
this is angle com pin sate I will demonstrate it later if you want to
change the zero instead of zero you call it 20 degrees or 90 degrees or 180 degrees you can add
this and the angle will be reflected accordingly and these three lines are for d1 we are defining
d1 pin analog one here and a state of d1 and also delay this delay time is the time if the
alarm is detected or the device is destabilized and the alarm is on you can keep it waiting for
certain time if you want to add that time added here and the same way you are defining the pin 2
and here then we put here the title which will be displayed on the screen here as you can see alarm
angle and rmd1 rnd2 this is the text it's coming here if you're using it for some robotic purpose
you can say towards arm or towards the machine or up or down whatever so it will be the straight
and this angle if it is and some angle you put angle if it is position of something at certain
way so you can change the text otherwise just leave it as f inside the setup we are
defining the serial monitor with 9600 board and then this is printing just a text and
and inside the loop we have three functions these are functions that I’ve defined at the
bottom of the code which I’m going to explain get angle we run this this will get angle
and when this runs it updates the angle when this runs it that is the alarm one and with
this when distance it updates the alarm too these are the variables that we have here the one state
and the two state so this is these two are updating that
and this is just printing the text title and this is the angle that we do something for example
and this is now printing it but if you want to do something you can put your f condition here
for example f angle is for example greater than 45 and then do something or less than
something whatever comparison that you want you can take action for your angle
and this is just printing state of d1 this is text this is a colon this text is coming from
the array at the top which I mentioned and here get angle is a function that is taking care of it
reads the analog pin which is from 96 to 927 from zero to 1023 is the analog input values but this
device outputs with the minimum it outputs 96 and with the maximum it outputs 927 I’ve experimented
with this and these are the values if yours is a little different you can move it and read it and
then change it accordingly and this is and I said if it is minimum 96 so that will be at 9 minus 90
degrees when I put it at minus 90 that's what I read and when I put it at 90 degrees I read
this one so we are using the map to convert these two values to angle and the result of calculation
will be here as an angle this is a global variable that is defined at the top of the code
this d1 alarm is using analog read it's measuring the voltage and we call it v out as a float and we
check if it is below 0.5 which means alarm is triggered so we said you want to stay
high and then there is a delay this was the delay initially it is set at zero but if you want to do
something as I mentioned you can set it at the top of the code so this in case if you want to
apply some delay it will work if you set it as 0 it will just quickly pass otherwise we
set the alarm as low and the same thing for the two alarm exactly the same thing except
it reads the d2 pin and state two will be updated and that's the complete explanation of code
and here is a demonstration as you can see when I try to keep it flat
we can get zero degrees on the serial monitor here that you see and I can tilt it can go
and here around 90 degrees so this is around 90 and then it can
if I go this way we can go minus 90. but we can adjust this and fix it for our purpose for example
if this is zero and this is your minus you can do so here on the com pin sate we can put 90
and let me upload it and now this is now your zero you can bring your zero here
and this is 90 and this will be 180 degrees you can change it to -90
and here this is your minus 90 and it can go here to minus 180
and this will be your zero degrees
so whichever way you want you can adjust it or if you're installing it in some angle you also you
can do so for example if you have already 20 degrees inclination so you can put 20
here
and here that 20 will be your zero
and here that 20 would be you are almost zero
it's hard for me to hold it and then based on that you can go to any angle that you want
the two pins that we have here these are alarms and you can adjust your flat angle for example
using these two potentiometers to keep it flat you just rotate it and if you rotate it
this will not turn on at this value let's say zero and then rotate this so this is now
zero and now it shows an angle here so at zero we can keep it off and here if you want to
get the values when the alarm runs as you can see two is zero because the light is zero and
if I put it now as you can see the two is on two is now it shows one and if I go this way
now d1 is turned on and you can see on the screen you can take some action if the devices tilted
from zero degrees so this is these two lights will show when it is deviating from zero degrees
and you can detect it if you use these two analog one and r2 that are already in the code
line to print it and here you can use d1 state and you can take action you can put your if statement
and this will turn this will be true if it detects that d1 is on and this d2 state is the one that is
detecting when d2 is on the led so you can take some action but
if you don't want to use these two because there this is for d2 this pin and this is for d1 and
they are occupying analog one and analog two so if you do need those alarm feature just disconnect
these two pin s and just use analog zero and you do need to connect any wire to d1 here
or to d2 so this we can use only one analog if the analog pins are needed for other purpose
please give me a feedback on my course by writing a review it's really appreciated thank you
please make sure to subscribe by clicking at 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