Saltar navegación

Activa JavaScript para disfrutar de los vídeos de la Mediateca.

Arduino: Multiple Input (native speaker) - Contenido educativo

Ajuste de pantalla

El ajuste de pantalla se aprecia al ver el vídeo en pantalla completa. Elige la presentación que más te guste:

Subido el 7 de febrero de 2022 por David G.

116 visualizaciones

Descargar la transcripción

hello today we are going to program 00:00:02
a new circuit similar to the ones 00:00:04
we've already programmed so we will use 00:00:06
a protoboard and arduino board as 00:00:09
always and click and drag three LED 00:00:12
we're going to connect them in a 00:00:22
similar way that we've connected them before 00:00:24
so we use a black wire to 00:00:27
connect it to the ground 00:00:29
and then of course we need three 00:00:32
protection resistors 00:00:34
and remember that each protection resistor all 00:00:40
three are going to be two hundred 00:00:43
and twenty ohms not kilo ohms 00:00:45
and they're connected to the cathode or 00:00:50
the straight side 00:00:52
okay so these three LED are going 00:01:06
to be connected to connectors thirteen twelve 00:01:09
and eleven 00:01:14
okay so these three LED are going 00:01:17
to be our output 00:01:19
now the new part today is that 00:01:22
we're going to learn to use two 00:01:24
switches because we want to use two 00:01:25
digital inputs so we're going to use 00:01:28
connector ten 00:01:31
and nine 00:01:37
so we add the switches 00:01:40
and then from connector ten we're going 00:01:43
to make this wire orange 00:01:45
and an orange wire again for the 00:01:51
second switch 00:01:52
remember that we're going to connect a 00:01:57
pull-down resistor so when we used the 00:01:59
single button it was a ten kilo 00:02:01
ohms pull down resistor so let's add 00:02:04
one to each switch and change it 00:02:09
to ten kilo ohms 00:02:11
and these are actually going to be 00:02:18
put into the center of the switches 00:02:20
sorry let's move these 00:02:21
and then we also need a five 00:02:29
volts connector so we are going to 00:02:30
connect the wire all the way down 00:02:33
from five volts 00:02:35
to this line and it'll be read 00:02:38
now I need another red connection here 00:02:42
because I want five volts to this 00:02:44
switch and the same with this one 00:02:46
and remember to connect it to the 00:02:53
same horizontal line that the five foot 00:02:55
wire is on sometimes we make mistakes 00:02:58
connecting wires and then the circuits don't 00:03:00
work but it's actually not related to 00:03:02
the programming it's just because of an 00:03:04
improper wire connection so make sure they're 00:03:06
always connected properly 00:03:08
so instead of having the button like 00:03:11
before I have two switches why because 00:03:13
we will manipulate them so that when 00:03:17
I press one of them i'll have 00:03:19
a single pointer single connection so if 00:03:21
I want to press the other one 00:03:24
I can't be pressing both at the 00:03:26
same time that's why I'm using a 00:03:27
switch 00:03:30
because remember when we discussed components we 00:03:30
said that switches have two permanent states 00:03:34
on and off that's why we need 00:03:36
two switches instead of two buttons because 00:03:39
if we use a button then the 00:03:42
moment we finish pressing the connection is 00:03:43
closed 00:03:46
okay 00:03:49
so that's why we're going to use 00:03:51
two switches and it'll make a lot 00:03:52
more sense when we see the simulation 00:03:54
later 00:03:55
so this switch is connected the same 00:03:58
way the button has been connected and 00:04:00
now there's no connection between this point 00:04:03
and this point 00:04:06
okay you can see this position so 00:04:08
here this wire is connected to the 00:04:10
ground through the pull-down resistor and then 00:04:12
the moment that there's a connection between 00:04:16
the orange and the red wires I 00:04:18
have five volts from here and then 00:04:20
the five volts will be in connectors 00:04:22
ten and the same for number nine 00:04:24
now for this simulation i'm going to 00:04:34
simulate the circuit this way 00:04:37
let's code and I'm going to program 00:04:40
it step by step 00:04:43
the first thing I need are two 00:04:46
variables 00:04:47
I'm going to name them input nine 00:04:50
and input ten because we're reading two 00:04:54
inputs from those numbers 00:04:56
input ten 00:05:03
now right now I haven't said anything 00:05:06
about the behavior of the arduino board 00:05:08
or the circuit and I'm going to 00:05:10
explain it while I'm programming so if 00:05:12
you think you miss something I just 00:05:15
haven't gotten there yet 00:05:17
now the first thing we're gonna do 00:05:21
is read numbers nine and ten so 00:05:22
let's find them here and we're going 00:05:26
to read nine 00:05:28
and again with ten 00:05:31
now we're going to use these readings 00:05:37
to define input nine and input ten 00:05:39
it means that we're reading these two 00:05:42
connectors and we are storing their values 00:05:44
into variables remember that variables are like 00:05:47
boxes and we store the values inside 00:05:50
of them 00:05:53
so here we are going to store 00:05:54
high or low depending on whether the 00:05:55
switch is on or off 00:05:58
and now we can move on to 00:06:05
the behavior so first of all I 00:06:06
need an if condition "si" remember if 00:06:09
now we have four possibilities here 00:06:14
with two switches they can either be 00:06:17
both on 00:06:19
both off or the first one on 00:06:21
and the second one off or the 00:06:25
first one off and the second one 00:06:27
on so I need to if or 00:06:29
see sections and therefore possibilities now to 00:06:31
compare we already know the sine equals 00:06:35
in the previous exercise 00:06:40
we've used that so I need to 00:06:41
have them here because I'm going to 00:06:43
use the and connector 00:06:45
so let's add two equals 00:06:49
and then we want to eat or 00:06:57
and to compare them 00:06:58
and put them together let's make it 00:07:01
smaller so it's easier to see 00:07:03
now there are two possibilities okay the 00:07:06
first possibility is that number nine will 00:07:08
be low or off and another possibility 00:07:10
is number ten is low or off 00:07:14
if nine is often ten is off 00:07:17
I'm going to use the and block 00:07:19
to combine both of them 00:07:22
so they can both be off now 00:07:31
let's combine them into this one big 00:07:33
and block we want the whole thing 00:07:35
and drag it over here 00:07:40
so I'm using this condition instead of 00:07:45
one single condition and combining them okay 00:07:47
this is the purpose of the exercise 00:07:50
is to combine two different conditions and 00:07:52
that's why we have two different inputs 00:07:54
so what do I want if both 00:08:00
of them are off well we can 00:08:01
consider that if both of them are 00:08:04
low then thirteen twelve and eleven are 00:08:05
low as well 00:08:09
those lights so we'll use three blocks 00:08:11
in a row 00:08:13
one for each lcd 00:08:20
make sure they're in the correct place 00:08:27
all connected to each other 00:08:28
so if nine and ten are off 00:08:31
I'm going to decide for my program 00:08:33
that thirteen twelve and eleven eli these 00:08:35
are all low why because that's just 00:08:37
what I want for the program so 00:08:40
let's do thirteen twelve and eleven 00:08:42
although 00:08:47
okay what else do I want well 00:08:54
I can just remove these three and 00:08:56
actually copy what we already have because 00:08:58
it's easier this way 00:09:00
so down here what happens if nine 00:09:03
is hide number switch nine as high 00:09:07
and ten is low well what do 00:09:09
we want let's just say that we 00:09:11
would like thirteen to be high why 00:09:13
not 00:09:16
so if we press this one thirteen 00:09:17
will be high 00:09:20
okay that's the second possibility now what 00:09:23
happens if nine is low or off 00:09:25
and ten is high or on it 00:09:28
means that if we're pressing this one 00:09:31
if ten is the only one that's 00:09:33
then let's say eleven is high so 00:09:37
eleven will shine it'll be high 00:09:39
this is just how I'm going to 00:09:44
decide to program this this time this 00:09:45
way 00:09:48
now what happens if both of them 00:09:51
nine and ten are high or an 00:09:53
ok we'll just because we want we 00:09:56
can try to program a blinking series 00:09:58
like we did before so we're going 00:10:01
to program a blink the way that 00:10:02
we know how to do it 00:10:04
it can duplicate 00:10:07
and remember that we need the wait 00:10:11
code 00:10:14
so duplicate this 00:10:20
and add the wait for the blinking 00:10:29
duplicate again and I'll have them all 00:10:35
low after waiting so shining on that 00:10:37
loop of on and off 00:10:41
okay do you see that have both 00:10:44
of them are low if both of 00:10:45
them are off then it's a blinking 00:10:47
program so realize that there are four 00:10:48
if blocks for each part because we 00:10:51
still only have four possibilities low and 00:10:53
low low and high high end low 00:10:56
and high and high and for every 00:11:00
possibility 00:11:03
I haven't programmed a different behavior so 00:11:03
now let's see if it works the 00:11:06
way that we've programmed okay 00:11:08
so start the simulation and both switches 00:11:13
are off 00:11:15
another appears to be a mistake somewhere 00:11:22
after switching this on 00:11:25
ok it's a problem with the liars 00:11:31
were missing our ground connection so be 00:11:33
careful with the ground we always need 00:11:35
to include that for our ladies 00:11:39
okay now can you see that all 00:11:45
three are connected to the ground and 00:11:46
now that the circuit is closed and 00:11:49
everything should work so let's start again 00:11:51
okay so again i think there's a 00:11:59
problem with the connection so let's see 00:12:04
if we can find the problem 00:12:06
ah no actually there is no problem 00:12:11
because it is running according to the 00:12:13
program so if the two of them 00:12:15
are low then there is a blink 00:12:18
it makes sense if the two of 00:12:20
them are high 00:12:22
and and we can scroll back up 00:12:24
here 00:12:27
hmm okay so I made a mistake 00:12:37
with the program so I'm going to 00:12:39
check it again low and low and 00:12:40
the last part is high and high 00:12:43
okay now if both of them are 00:12:47
switched on we want the blink 00:12:49
if both of them are off then 00:12:53
the lights are low 00:12:55
there we go so on is when 00:12:59
we want the blank ok now it's 00:13:01
right 00:13:02
so it's important that when you program 00:13:05
you check the behavior of your programming 00:13:06
making mistakes is not a problem but 00:13:09
just check the work okay so now 00:13:11
the two of them are off 00:13:13
nothing happens and they're low 00:13:16
if I press the first one 00:13:21
this one is ten 00:13:24
the two of them are high 00:13:26
these two now I'm going to modify 00:13:31
it so that just eleven is high 00:13:33
instead 00:13:35
so go over here 00:13:37
to our tennis high 00:13:40
and just eleven will be high instead 00:13:47
so can you see the difference now 00:13:52
and let's start the simulation again and 00:13:54
now both of them are off and 00:13:56
nothing happens 00:13:57
and if I press this one then 00:14:01
the shining perfect so it's according to 00:14:02
the program if just the second one 00:14:04
is on then this one is shining 00:14:07
perfect just like we programmed and if 00:14:09
both of them are on we have 00:14:12
the blinking program so it works the 00:14:13
circuit behaves according to the program now 00:14:16
we've made some mist 00:14:19
stakes but that's not a big problem 00:14:20
because we can always check and then 00:14:21
compare our behavior with our program to 00:14:23
the same way that when you simulate 00:14:27
the circuit you can check the behavior 00:14:29
to that we've connected everything okay so 00:14:31
I will repeat this circuit 00:14:34
if nothing is connected then nothing happens 00:14:37
if one of them is on then 00:14:41
one is shining 00:14:43
and if the other one is on 00:14:45
then the other one is shining and 00:14:47
if both are on we have the 00:14:49
three elegies blinking now the most important 00:14:51
thing is just realizing that there are 00:14:55
always four possibilities here low and low 00:14:57
low and high high end low and 00:15:01
high and high okay 00:15:04
okay so check all four possibilities and 00:15:05
make sure to compare them in the 00:15:08
program with their behaviors okay so this 00:15:10
is going to be your exercise for 00:15:14
today with these two switches and four 00:15:16
possibilities good luck 00:15:20
Idioma/s:
en
Autor/es:
David Gonzalez Arroyo, Alyssa Fantel
Subido por:
David G.
Licencia:
Reconocimiento - No comercial - Compartir igual
Visualizaciones:
116
Fecha:
7 de febrero de 2022 - 23:45
Visibilidad:
Público
Centro:
IES MARIE CURIE Loeches
Duración:
15′ 23″
Relación de aspecto:
1.78:1
Resolución:
1920x1080 píxeles
Tamaño:
178.01 MBytes

Del mismo autor…

Ver más del mismo autor


EducaMadrid, Plataforma Educativa de la Comunidad de Madrid

Plataforma Educativa EducaMadrid