Saltar navegación

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

Arduino: digital 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 23 de enero de 2022 por David G.

109 visualizaciones

Descargar la transcripción

hello today we are going to make 00:00:02
a new circuit as always we need 00:00:04
a protoboard and the arduino board 00:00:07
and this circuit is going to use 00:00:11
an LED as an output 00:00:13
so we can drag the LED here 00:00:18
and we're going to connect it the 00:00:21
same way that we always have so 00:00:22
we need the ground connection over here 00:00:24
to the horizontal line 00:00:26
and the wire will be black 00:00:29
and now we will connect the ground 00:00:34
to this terminal from the cathode and 00:00:36
this wire is going to also be 00:00:39
black 00:00:40
and of course we need a protection 00:00:47
resistor and remember that the protection resistor 00:00:49
is always two hundred and twenty ohms 00:00:52
now we connect it from the anode 00:00:56
side and we're going to control the 00:00:58
LED using connector number thirteen or pin 00:01:01
number thirteen 00:01:05
I'm going to shift it over so 00:01:13
you can see it more clearly but 00:01:15
the connections exactly the same this way 00:01:16
it's just easier to see it and 00:01:18
this wire is going to be green 00:01:22
so now you can see that I 00:01:26
have closed the circuit for connector number 00:01:27
thirteen to the LED and we go 00:01:30
back to the ground 00:01:33
now this is the output part so 00:01:38
we can control the LED from the 00:01:40
arduino board which will either shine or 00:01:41
not it just depends on what we 00:01:44
want and how we program it 00:01:46
the new part is that we're going 00:01:50
to add a button and I'll drag 00:01:51
it over here so now here's how 00:01:53
we connect the button this is going 00:01:56
to be the standard way of connecting 00:01:58
a button every time we use one 00:02:00
we're going to use the five volt 00:02:02
connection from down here so we create 00:02:05
a wire 00:02:08
from that port 00:02:09
up here 00:02:12
and this wire will be red because 00:02:14
that is the standard wire color for 00:02:16
the five volt connection so now we 00:02:18
have the wire in this position and 00:02:21
from this side of the button we 00:02:24
will create a wire connected to position 00:02:27
twelve 00:02:30
so here from the side 00:02:34
drag it to twelve and this one 00:02:38
can be orange 00:02:39
and now we also need a pull 00:02:43
down resistor the pull-down resistor is going 00:02:44
to be ten kilo ohms 00:02:47
and it's going to be connected from 00:02:51
here remembering that the horizontal line is 00:02:54
connected to the ground so do you 00:02:58
see that 00:03:00
so now I will explain how this 00:03:04
works if the button is pressed if 00:03:05
you click on it while the simulation 00:03:08
is running there will be a connection 00:03:09
between this orange wire and the red 00:03:12
one 00:03:16
so because there's a connection from one 00:03:19
side to the other those five volts 00:03:22
will travel over here in pin twelve 00:03:25
but if we don't press the button 00:03:30
then there will be no connection between 00:03:33
these two points 00:03:34
so this point will be connected to 00:03:37
the ground through this resistor meaning that 00:03:39
we will have nothing here and nothing 00:03:43
and twelve 00:03:45
so if we don't press the button 00:03:47
we have zero in pin twelve but 00:03:48
if we press it then we now 00:03:51
have five volts because of the red 00:03:53
wire 00:03:55
now if any of this hasn't made 00:03:58
sense so far you can rewind and 00:03:59
just watch and listen to that explanation 00:04:01
again 00:04:03
now like always we need the program 00:04:06
so we're going to click code 00:04:10
and 00:04:13
now we want to remove the previous 00:04:15
program and the first thing we need 00:04:16
is an input 00:04:19
so we want this first block 00:04:23
up here because we want it to 00:04:26
read pin number twelve so that's what 00:04:28
we select it 00:04:31
and then we need something else called 00:04:33
a variable 00:04:36
now a variable is a kind of 00:04:42
box to store the value or number 00:04:44
that we have read 00:04:46
so we're going to click here 00:04:49
to create a variable and the name 00:04:51
for this variable will be input because 00:04:53
it's the one that we're reading 00:04:56
so now we are going to use 00:04:58
this block to define the input and 00:05:00
then connect the blocks together like this 00:05:03
so the right side is the reading 00:05:06
for number twelve and this reading is 00:05:08
going to be stored inside the input 00:05:10
like a box to save or store 00:05:13
this number for twelve 00:05:14
so now that we have our input 00:05:18
in the variable 00:05:20
we are going to add controls so 00:05:23
that we can check the value of 00:05:25
the input that we have and we 00:05:27
want to compare the input with the 00:05:29
value for example 00:05:30
so we need a block from the 00:05:35
math section 00:05:36
and we're going to use 00:05:40
this one here 00:05:44
we're going to use the section more 00:05:47
later but for now the only block 00:05:49
we're gonna use is this second one 00:05:50
so we can compare the two values 00:05:53
we can compare if one of them 00:05:55
is less than less than or equal 00:05:57
equal to not equal to greater or 00:06:00
greater than or equal to and right 00:06:02
now we want equal because we 00:06:04
you want to compare the input 00:06:06
yeah here's the input 00:06:10
so i don't want a number I 00:06:13
want two possibilities high or low because 00:06:15
these are digital inputs so we can't 00:06:18
compare using a number 00:06:20
so digital just means high or low 00:06:23
and analog means a value or a 00:06:25
number so if input equals high then 00:06:27
we must be pressing this button because 00:06:32
it's all related to twelve since that 00:06:34
value is stored here 00:06:36
and now we want to compare this 00:06:39
value too high 00:06:41
so that what happens if we press 00:06:44
the button so for instance if I 00:06:45
want number thirteen high well how do 00:06:47
I do it 00:06:50
so we need to define the pathway 00:06:54
for number thirteen 00:06:56
okay so with this program if I 00:07:08
press the button the LED will shine 00:07:11
first it reads the value stored in 00:07:14
input a compares the input with high 00:07:16
and then if the input equals high 00:07:19
then thirteen will be high 00:07:21
and see no in english means if 00:07:25
not or or else 00:07:28
so that's what happens if the condition 00:07:37
is not true because this is just 00:07:39
a condition 00:07:40
and what we want is if we're 00:07:43
not pressing the button 00:07:45
or if the input is low then 00:07:48
we will define that here 00:07:51
so now if we press the button 00:08:04
we've stored that value here and we 00:08:06
compare the value with high and if 00:08:08
the value is high then the lcd 00:08:10
will shine because it's connected to thirteen 00:08:12
and if the condition is not met 00:08:15
the LED connected to thirteen will not 00:08:17
shine it will be low 00:08:20
so now we have connected everything the 00:08:28
output part we have the input part 00:08:30
including the button and pull down resistor 00:08:33
and we have the block so we 00:08:35
have everything we need so if we 00:08:36
start the simulation nothing will happen yet 00:08:38
but if we press the button then 00:08:40
the LED will shine and if I 00:08:42
stop pressing the LED doesn't shine because 00:08:44
that's how we programmed 00:08:46
it so that's the exercise today just 00:08:47
repeating the example okay 00:08:50
Idioma/s:
en
Autor/es:
David Gonzalez Arroyo, Alyssa Fantel
Subido por:
David G.
Licencia:
Reconocimiento - No comercial - Compartir igual
Visualizaciones:
109
Fecha:
23 de enero de 2022 - 15:33
Visibilidad:
Público
Centro:
IES MARIE CURIE Loeches
Duración:
09′
Relación de aspecto:
1.78:1
Resolución:
1920x1080 píxeles
Tamaño:
23.85 MBytes

Del mismo autor…

Ver más del mismo autor


EducaMadrid, Plataforma Educativa de la Comunidad de Madrid

Plataforma Educativa EducaMadrid