Activa JavaScript para disfrutar de los vídeos de la Mediateca.
Arduino: analog input (native speaker) - Contenido educativo
Ajuste de pantallaEl ajuste de pantalla se aprecia al ver el vídeo en pantalla completa. Elige la presentación que más te guste:
hello until now we have studied digital
00:00:00
inputs and digital means that there are
00:00:04
only two possibilities high and low for
00:00:06
instance when we press a button the
00:00:10
arduino board read high with five bolts
00:00:12
and when we were not pressing the
00:00:15
button the board was zero or low
00:00:17
they mean the same so in the
00:00:20
same way then we have an LED
00:00:22
like this one that's connected
00:00:25
to thirteen
00:00:27
for example if there was a current
00:00:30
here then the output was high and
00:00:32
the LED was shining but if there
00:00:34
was no output the LED didn't shine
00:00:36
or it was low
00:00:39
okay hi the LED shines low the
00:00:42
LED doesn't
00:00:45
two options but today we're going to
00:00:48
study something a little bit more complicated
00:00:50
we're going to study analog inputs
00:00:53
analog means that instead of having zero
00:00:57
or five volts low or high we
00:01:00
have any voltage from zero to five
00:01:03
so it means we can have one
00:01:06
two three one and a half two
00:01:08
and a half two point two five
00:01:10
three point four anything any range
00:01:13
so every value from zero to five
00:01:17
in that range can be read
00:01:19
so how do we do that we
00:01:22
are going to use a voltage divider
00:01:25
like this one
00:01:27
okay we have a voltage divider here
00:01:30
on the board and this big picture
00:01:32
on the screen
00:01:33
now it has three terminals the one
00:01:37
on the left will be connected to
00:01:39
five volts through the red wire
00:01:41
and the one on the right will
00:01:45
be connected to the ground through the
00:01:47
black wire
00:01:49
and then the one in the middle
00:01:52
is going to be the terminal variable
00:01:54
and it's going to be connected here
00:01:56
to this terminal at the bottom called
00:01:58
a zero
00:02:00
two can you see that here on
00:02:08
the bottom right corner of the arduino
00:02:10
board there are six analog inputs that
00:02:12
say analog in it means that we're
00:02:14
going to use these six connectors to
00:02:17
read analog inputs so by using these
00:02:19
connectors we can read a voltage any
00:02:22
voltage from zero to five
00:02:24
and we want to use a voltage
00:02:27
divider to read them this way and
00:02:29
we use the connector or the terminal
00:02:31
in the middle here that is connected
00:02:33
to a zero the green wire so
00:02:36
how does it work so the terminals
00:02:41
on the left and the right don't
00:02:43
move there they are a fixed range
00:02:45
the one on the left for instance
00:02:48
will have five the one on the
00:02:50
right will have zero
00:02:51
the one that moves is the one
00:02:54
in the middle so in real life
00:02:55
and during the simulation you will be
00:02:57
able to click and drag to move
00:02:59
the dial i'll start a simulation to
00:03:02
show you
00:03:04
and in the program that if I
00:03:06
click and drag it moves
00:03:09
you can see that here
00:03:12
okay now for the explanation so the
00:03:18
one in the middle will move and
00:03:21
the closer it is to the right
00:03:23
side the one that is connected to
00:03:25
the black wire the ground the closer
00:03:27
this variable will be to zero
00:03:30
and the closer the terminal is to
00:03:33
the terminal on the left the closer
00:03:36
the voltage will be to five volts
00:03:38
so by clicking the middle and moving
00:03:42
it will be sending different voltages from
00:03:45
a zero
00:03:47
from zero to five volts somewhere in
00:03:51
that range
00:03:54
okay so now today's exercise we're going
00:03:59
to take a look at the blocks
00:04:02
just forget about this last block though
00:04:03
you do not need it for now
00:04:06
we'll address it later
00:04:07
we are going to read this as
00:04:10
zero connector using the purple block for
00:04:11
reading analog input a zero you can
00:04:14
read from a zero to a five
00:04:18
but now we're going to read a
00:04:21
zero and we're going to store it
00:04:22
here in the input variable
00:04:25
now we've already defined the variable and
00:04:30
here these four blocks
00:04:33
without the last one forget about that
00:04:37
well by now you can probably identify
00:04:41
that these four together are a blink
00:04:44
you see how we have
00:04:48
thirteen high
00:04:50
and we wait thirteen low and we
00:04:52
wait so it's a blinking program
00:04:55
but instead of having a fixed period
00:04:58
of time we are using the variable
00:05:01
that we have read as the blinking
00:05:04
period of time because the input doesn't
00:05:06
read numbers from zero to five volts
00:05:09
so obviously we're reading values from zero
00:05:12
to five volts but they will be
00:05:15
translated from zero
00:05:17
oh to one thousand twenty three okay
00:05:18
we can see this in the simulation
00:05:22
so I'm going to add this last
00:05:33
block just to show these values that
00:05:34
appear here on the bottom
00:05:36
I want to start the simulation now
00:05:39
watch the pointer turn on the dial
00:05:40
now you can see where reading three
00:05:44
hundred and forty eight
00:05:46
if I move it all the way
00:05:49
to the right terminal we're only reading
00:05:50
zero
00:05:52
the ground if I move it a
00:05:54
little bit higher were reading eighty two
00:05:56
if I move higher
00:06:00
we're reading to twenty five
00:06:03
and if I move a little bit
00:06:06
closer to the red one
00:06:07
it'll get higher let's wait
00:06:10
it's six hundred fourteen
00:06:13
and if I move even closer to
00:06:16
read
00:06:18
nine twenty one so it means that
00:06:21
we're reading these values instead of the
00:06:23
values simply being from zero to five
00:06:26
they're reading from zero to one thousand
00:06:28
twenty three there is a proportional relationship
00:06:31
the highest is one thousand twenty three
00:06:35
so this is because the arduino board
00:06:39
uses integral numbers again let's forget about
00:06:41
the last block
00:06:45
because we are going to read a
00:06:47
zero and store it in this variable
00:06:50
and we are using the variable multiplied
00:06:54
by two as a blinking period of
00:06:56
time for the LED the LED is
00:06:58
connected the same way as always terminal
00:07:01
thirteen with ground connection and the protection
00:07:03
resistor at
00:07:06
two hundred and twenty ohms
00:07:08
so again let's forget about the last
00:07:16
block we're not going to use it
00:07:18
anymore and I'm going to get rid
00:07:19
of it
00:07:20
the idea is that we're controlling the
00:07:24
period of time the lcd will shine
00:07:27
by using the analog input so let's
00:07:29
let's actually start the simulation again
00:07:33
and you will see that the closer
00:07:36
the connectors to zero the shorter of
00:07:38
the shorter the period of time that
00:07:41
the LED will be shining and so
00:07:43
the faster it will blink
00:07:46
but if the number is higher
00:07:49
then the period of time between blinks
00:07:53
will be higher and the blinking will
00:07:55
appear slower
00:07:57
so this is just your first exercise
00:08:00
okay you're going to reproduce this circuit
00:08:03
and programme it now if you program
00:08:05
it this way you'll have half of
00:08:08
the assignment done
00:08:09
so this is the first part
00:08:12
okay let me stop the simulation and
00:08:18
now to complete it and receive the
00:08:20
second half of the assignment you will
00:08:22
have to use a second analog dial
00:08:24
you will connect it the same way
00:08:30
it has been connected through a red
00:08:32
wire to five volts
00:08:34
maybe you will connect it in a
00:08:37
different way and but with five volts
00:08:38
here another red wire
00:08:41
and the ground connection
00:08:45
as well with the black wires
00:08:49
this will be ground
00:08:58
so that's the red and I mean
00:09:01
need ground
00:09:03
so there's a second connection to a
00:09:05
one analog one and you will repeat
00:09:07
this connection with a cell second LED
00:09:09
connected using a second protection resistor as
00:09:11
well
00:09:15
and this one will be connected to
00:09:17
twelve
00:09:21
just right next to the first one
00:09:23
okay
00:09:25
another protection resistor
00:09:28
two hundred twenty
00:09:31
so I'll repeat the same connection with
00:09:34
a second LED another resistor and the
00:09:36
wires so you will have two LED
00:09:40
and two voltage dividers and program
00:09:42
it a different way so instead of
00:09:44
controlling the blinking time you will use
00:09:46
the control block since you now have
00:09:49
two variables in
00:09:51
put one and input two for instance
00:09:53
and name them
00:09:55
input one
00:09:58
and you will read them the same
00:10:01
way that we read the first one
00:10:03
and again the same with the second
00:10:05
one
00:10:06
let's make this again for input two
00:10:15
and that'll be called input two and
00:10:21
you're going to read that for a
00:10:23
a one instead of a zero
00:10:25
and then here you will compare with
00:10:29
the if block you already know how
00:10:31
to compare higher and lower so if
00:10:33
input one is higher than input two
00:10:36
then one of the l these will
00:10:40
blink
00:10:41
if the other one is higher than
00:10:43
the first one
00:10:45
it means the opposite condition so maybe
00:10:47
the other ltd will blank or something
00:10:50
like that
00:10:52
okay this is just one example I'm
00:10:59
not going to complete this program on
00:11:02
the video because you will complete it
00:11:05
by yourselves
00:11:07
so for example if the first condition
00:11:11
is true then input zero is lower
00:11:13
than input one and maybe thirteen will
00:11:15
shine if a one is higher than
00:11:17
a zero maybe twelve will shine you
00:11:21
will compare the two variables input one
00:11:23
input two
00:11:27
input one input two
00:11:29
and then you will decide which LED
00:11:32
is going to shine in the
00:11:34
program may be number thirteen here maybe
00:11:35
number twelve here
00:11:39
okay so you complete the code
00:11:42
currently it is not complete if you
00:11:44
try to simulate this as it is
00:11:46
it won't work because it's not fully
00:11:48
programmed so you will complete it
00:11:51
and this is the second part of
00:11:54
the exercise okay rewatch this if you
00:11:55
need to and good luck
00:11:58
- Idioma/s:
- Autor/es:
- David Gonzalez Arroyo, Alyssa Fantel
- Subido por:
- David G.
- Licencia:
- Reconocimiento - No comercial - Compartir igual
- Visualizaciones:
- 137
- Fecha:
- 11 de febrero de 2022 - 14:55
- Visibilidad:
- Público
- Centro:
- IES MARIE CURIE Loeches
- Duración:
- 12′ 04″
- Relación de aspecto:
- 1.78:1
- Resolución:
- 1920x1080 píxeles
- Tamaño:
- 35.82 MBytes