Activa JavaScript para disfrutar de los vídeos de la Mediateca.
Arduino: multiple input - 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, today we are going to program a new circuit. It's similar to the ones we have
00:00:00
already programmed. We will use the protoboard, the Arduino board, and we are going to use
00:00:08
three LEDs. So we click and drag, click and drag, and click and drag.
00:00:15
And we are going to connect them in a similar way we have connected them before.
00:00:24
We use a black wire here, because it's connected to the ground, this is the ground, and we are going to use the three protection resistors.
00:00:30
Remember that the protection resistor, the three of them, every protection resistor is going to be 220 ohms, not kilo ohms, ohms.
00:00:43
and again with another protection resistor again 220 ohms and again with
00:00:54
the third one here 220 ohms okay and this LEDs the three of them are going to
00:01:04
connected to 13, 12 and 11. Ok, so these three LEDs are going to be our output and
00:01:13
now the different part because we are going to use these switches. We are going
00:01:27
to use two switches because we are going to use two digital inputs. We are going
00:01:33
to use 10. I'm going to use an orange wire. Why orange? Just because. And the same orange
00:01:41
here. And remember that we are going to connect, we need a pull-down resistor. You remember
00:01:53
when we have, when we used the single button, it was 10 kilo ohms. The pull-down resistor
00:02:03
was a 10 kilo ohms one. And again, a 10 kilo ohms one here. And here, I'm sorry, this one
00:02:09
is going to be here, and this one is going to be here. And 10 kilo ohms, both of them.
00:02:18
Okay. And we also need a 5 volts connector. We take it here, 5 volts, and I'm going to
00:02:27
connected here, and this one is going to be red. And I need
00:02:36
a red connection here. I mean red because it's not
00:02:40
black, right? Because I want five volts here
00:02:44
and the same with this one. I made
00:02:48
a mistake. This one has to be connected here. Can you see the difference? And the same with
00:02:52
this one. Right. Sometimes we make mistakes
00:02:56
connecting wires, and that's why sometimes the circuits
00:03:00
don't work this is not nothing related to the programming is related is because we have we
00:03:04
haven't connected the wires properly so here instead of having the usual button i have two
00:03:12
switches why two switches because i'm going to manipulate them this way when i press one of them
00:03:19
i have a single pointer pointer if i want to press the other one i cannot be pressing by both
00:03:24
positions at the same time. So, that's why I'm going to use a switch. A switch has, remember,
00:03:31
we studied the switch in the classroom. The switch, I mean, switches have two permanent
00:03:37
states on and off. That's why we need two switches instead of two buttons because if
00:03:44
we use a button, the moment we finish pressing, the connection is closed, okay? So, that's
00:03:49
That's why we are using two switches.
00:03:57
You will understand it better later in the simulation.
00:04:01
So this switch is connected the same way the button has been connected.
00:04:06
Now there is no connection between this point and this point, okay, can you see this position?
00:04:11
So here this wire is connected to ground through the pull-down resistor.
00:04:16
The moment there is a connection between this wire and this wire, I have five volts here
00:04:22
and five volts will be red here in the connector 10,
00:04:26
and the same for number nine, okay?
00:04:31
Now, the simulation.
00:04:34
What do I want to do?
00:04:36
I want to simulate the circuit this way.
00:04:38
I'm going to, first of all,
00:04:41
I'm going to program it step by step.
00:04:42
The first thing I need are two variables.
00:04:44
I'm going to name them input nine and input 10.
00:04:49
Why? Because we are reading two inputs, from 9 and from 10.
00:04:54
The second variable will be input 10.
00:04:59
For the moment, I haven't said anything about the behavior of the circuit.
00:05:03
I'm going to explain it while I'm programming it.
00:05:10
Don't worry if you don't understand because I haven't said anything.
00:05:12
So, the first thing we are going to do is reading number 9 and number 10.
00:05:15
We have Entraje, Ler, Pasador, Digital.
00:05:22
So we are going to read 9 and we are going to read 10
00:05:26
because they are the ones we are reading, 9 and 10.
00:05:31
And we are going to use these readings to define input 9
00:05:35
and to define input 10.
00:05:42
It means we are reading these two connectors and we are storing their values into variables.
00:05:46
Remember that the variables are like boxes and we can store values inside them.
00:05:56
Here we are going to store high or low depending if the switch is on or off.
00:06:03
So, now, the behavior. What do I want?
00:06:10
Well, first of all, I need an if.
00:06:14
Remember the si?
00:06:17
There are four possibilities.
00:06:19
The two switches on, the two switches off,
00:06:23
the first one off and the second one on,
00:06:26
and the first one off and the second one on, or vice versa.
00:06:28
Anyway, I want, I need two ifs.
00:06:31
Si, si entonces.
00:06:35
And there are four possibilities.
00:06:37
And to compare, remember that we already know
00:06:40
this one equals
00:06:43
in the previous exercises we have used this one equal
00:06:48
and equal. I need two of them because here I'm going to use
00:06:53
the and connector. I'm going to make it smaller to make it a little bit easier
00:06:58
because there are two possibilities. First possibility
00:07:02
number nine, low. Let's have a look here
00:07:07
no, low and another possibility is
00:07:14
number 10 low. And if 9 is low and 10 is low, to combine both of them, I'm going to use the
00:07:22
i, the ant in English. Can you see that I'm combining them? So here the condition is if 9 is low
00:07:37
and 9 is low, something will happen. I click and drag. So I'm using this condition. Instead of
00:07:47
Instead of using one single condition, we are combining two conditions using the AND, okay?
00:07:56
This is the purpose of this exercise, combining two different conditions.
00:08:01
That's why we have two different inputs.
00:08:06
What do I want if both of them are off?
00:08:09
I don't know.
00:08:12
Whatever you want.
00:08:12
So we are considering that if both of them are low, 13, 12, 11 are low.
00:08:14
It's really easy.
00:08:22
We use three blocks, like, oh, I'm sorry, I made a mistake, be careful when you are moving and dragging the blocks, so if 9 and 10 are low, I will decide that 13, 12, and 11, the three of them are low.
00:08:22
Why? Just because. Just because I want.
00:08:48
Okay. What else? Anyway, I'm going to remove
00:08:53
these three ones and I'm going to copy because it's easier this way. Duplicate.
00:08:57
What happens if 9 is high
00:09:01
and 10 is low? I don't know. What do we
00:09:04
want? For instance, we want that 13 is high. Why not?
00:09:11
13. If we press this one, this one will be high.
00:09:15
Why not? Okay, this is the second possibility. What happens if 9 is low and 10 is high?
00:09:18
So it means that if we are pressing this one or if this one is on, for example, I want this one is
00:09:39
is high. Why not? So this one is 11, 11 high. Okay. Why? Just because I am programming it
00:09:48
this way. And what happens if the two of them, 9 and 10, are high? Okay. Just because we
00:10:03
want, we can program a blinking. So we are going to program a blink the way we know it.
00:10:16
Now we use await, and now I'm going to duplicate this part of the code. Baja, low, low, and
00:10:28
low. Do you agree that if both of them are low, sorry, low and low, if both of them are
00:10:41
low, if 9 and 10 are low, this is a blinking program. Okay. So realize that there are four
00:10:49
if blocks, four if parts, because we have the four possibilities. Low and low, low and
00:10:57
high, high and low, and high and high. And for every possibility, I have a different
00:11:02
behavior. Okay. Let's see if it works the way we have programmed it. Okay. Okay. Both of them are
00:11:09
off. The three lights are off, as expected. If this one is... I made a mistake. I don't know.
00:11:18
Ah, where's the mistake? Again, a problem with the wires. There is no ground connection.
00:11:28
be careful with the grounds black can you see that now that the three resistors are connected
00:11:34
to ground now i'm i am closing the circuit now everything will work let's start again
00:11:50
okay okay okay again there is a problem with the connections
00:11:56
Where's the problem? Ah no, there's no problem
00:12:12
because it's according to the program. If the three of them
00:12:23
are low, if the two of them are low, there is a blink
00:12:27
It makes sense. If, oh I'm sorry, if the two
00:12:30
of them are high, this is, no
00:12:39
I made a mistake. I made a mistake with the program
00:12:46
I want to check it again. Alta, baja, baja. And it's the last part of this alta, alta, okay?
00:12:49
Alta, alta. If both of them are high, we want a blink. If both of them are low, alta, alta, baja, baja, alta, alta, baja, baja.
00:13:00
They are low, alta, alta, it's a blink, okay?
00:13:13
It's important that when you program, you check the behavior with your programming.
00:13:16
It's not a big problem making mistakes. Now, the two of them are low.
00:13:22
Baja, baja. Nothing happens. They are low. If I press this one,
00:13:27
this one is 10. Alta.
00:13:32
Two of them are high. I'm going to modify it just because I want to. I want to
00:13:42
to consider that just 11 is low, is high and mean. Can you see the difference now? Okay,
00:13:47
let's start the simulation again. Both of them are off, nothing happens. If I press
00:13:56
this one, this one is shining, perfect, according to the program. If just this one is on, this
00:14:03
one is shining, perfect, according to the program. And what happens if the two of them
00:14:10
are high, the blinking program. So the program works, the circuit behaves according to the
00:14:14
programming. We have made some mistakes, but this is not a big problem, it's not a big issue,
00:14:22
because we can check, we can compare, we program with the behavior, the same way that when you
00:14:27
simulate the circuit, you can check the behavior with your program, with the way you have connected
00:14:32
or the way you have connected everything, okay? So this is the circuit, okay? I repeat the behavior.
00:14:39
If nothing is connected, nothing happens. If one of them is connected, this one is shining.
00:14:45
If the other one is connected, this other one is shining. And if both of them are connected,
00:14:51
there is a blink. The three of them, the three LEDs are blinking, okay? So the important thing
00:14:57
is realizing that there are four possibilities baja baja low low high low low high and high high
00:15:03
okay check the four possibilities don't make the same mistake i made and compare with the
00:15:10
compare the four possibilities the four behaviors okay
00:15:19
it's not it's not difficult okay so this is the exercise for today good luck
00:15:23
- Autor/es:
- David Gonzalez Arroyo
- Subido por:
- David G.
- Licencia:
- Reconocimiento - No comercial - Compartir igual
- Visualizaciones:
- 306
- Fecha:
- 10 de enero de 2021 - 18:22
- Visibilidad:
- Público
- Centro:
- IES MARIE CURIE Loeches
- Duración:
- 15′ 29″
- Relación de aspecto:
- 1.78:1
- Resolución:
- 1920x1080 píxeles
- Tamaño:
- 49.53 MBytes