Saltar navegación

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

Arduino: random (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 30 de enero de 2022 por David G.

118 visualizaciones

Descargar la transcripción

Hello. In this exercise we are 00:00:00
going to reuse a previous circuit the 00:00:05
one that we made with the digital 00:00:08
input so here we can find all 00:00:10
the circuits that we've already made and 00:00:13
we can duplicate whichever we choose for 00:00:15
instance since we're going to use a 00:00:18
digital 00:00:19
input we click on the wheel 00:00:20
here and then we can duplicate it 00:00:22
or copy it 00:00:25
if we wait a second 00:00:30
then a copy of the circuit will 00:00:33
appear now in this exercise we're going 00:00:35
to use almost the same connections we 00:00:37
are going to use the digital input 00:00:40
with a button and the pull-down resistor 00:00:41
and we're going to use LED 00:00:45
as output but here instead of having 00:00:46
just one of them we're going to 00:00:49
use four of them 00:00:51
so the first thing we need to 00:00:53
do is make a little bit of 00:00:54
room so I'm going to click and 00:00:55
drag the button over and then the 00:00:57
wire and the pull-down resistor remember that 00:01:00
this is a ten kilo ohms one 00:01:04
and I'm going to click and drag 00:01:07
the input wire 00:01:09
I'm going to use pin numbers thirteen 00:01:12
twelve eleven and ten to control the 00:01:14
four LED so I'm going to 00:01:16
click and drag the input wire from 00:01:19
the button to number nine 00:01:22
and now I'm going to click and 00:01:26
drag the four LED just by 00:01:27
adding three more to the one that 00:01:29
we have 00:01:31
therefore I will also need three more 00:01:37
resistors 00:01:39
and remember all of them are connected 00:01:41
to the anode the pin that is 00:01:43
not straight 00:01:44
now remember for the LED we 00:01:49
need to change these values to be 00:01:51
two thousand two hundred and twenty ohms 00:01:52
because this is the value that we 00:01:55
need to protect the LED and remember 00:01:56
that ohms and kilo ohms are not 00:01:59
the same thing 00:02:02
so now I'm going to connect the 00:02:12
LED using the wires and the 00:02:14
first connection I want is to make 00:02:17
the four black wires that are connected 00:02:19
to the ground 00:02:21
we'll make them all black like always 00:02:24
and be careful when you draw the 00:02:31
wires because sometimes you make a mistake 00:02:33
and you don't realize that you've made 00:02:36
a mistake so you can just delete 00:02:38
what 00:02:40
what you do 00:02:42
and start over 00:02:44
okay so now I have a single 00:02:46
wire and these four wires are connected 00:02:47
to the ground because of this horizontal 00:02:50
line you see that the horizontal line 00:02:53
is connected to the ground through these 00:02:55
wires and now I need a connection 00:02:56
from twelve to this one from eleven 00:03:00
to this one from ten 00:03:03
to this one and now that I 00:03:07
have everything I need with all the 00:03:09
components 00:03:10
so now I need to program the 00:03:12
circuit so I'm going to open the 00:03:14
coding window and we just want to 00:03:16
modify the program we already have because 00:03:19
some of the possibilities and ideas are 00:03:22
the same so I'm not going to 00:03:24
get rid of all of it 00:03:26
and again I'm reading the input for 00:03:29
number nine so instead of reading from 00:03:31
number twelve now I'm reading from nine 00:03:34
so we modify that here 00:03:36
so I have a variable that I 00:03:40
read from number nine and it's stored 00:03:41
in this variable so if this variable 00:03:43
or input is high then something would 00:03:47
happen here and if the input is 00:03:49
not high then something else will happen 00:03:52
down here that will program 00:03:55
so the first thing we need is 00:03:58
a random number so if we go 00:03:59
to the green library about math there 00:04:02
is a block here related to random 00:04:05
numbers that allows us to generate one 00:04:08
from a range now I want a 00:04:11
random number from ten 00:04:14
two thirteen because these are our LED 00:04:17
connector pin numbers so it has 00:04:19
to be somewhere between these four 00:04:22
I also realize that there is a 00:04:26
bar down here so if it looks 00:04:28
like there's not enough room just click 00:04:30
and drag this and you can see 00:04:31
everything 00:04:33
now there's one more thing I almost 00:04:45
forgot before we move on is that 00:04:47
if I have a random number here 00:04:49
I still need to store it somewhere 00:04:51
so I'm going to create a new 00:04:53
variable under variables we can name it 00:04:56
anything we want but I'm going to 00:04:59
use output because this random number will 00:05:01
the output that will make the LED 00:05:05
shine so just like we did before 00:05:07
I'm going to define output using this 00:05:10
random number so output will have a 00:05:12
random number from ten to thirteen 00:05:16
okay so what happens if I press 00:05:21
the button is one of the LED 00:05:23
these will shine well which one 00:05:26
it just depends on the random number 00:05:29
generated 00:05:31
so I have to check the value 00:05:34
of the output now to do this 00:05:36
I'm going to use the comparison block 00:05:39
again 00:05:41
we will use the equal sign and 00:05:43
I want to check the value of 00:05:45
the output so for instance if output 00:05:47
equals thirteen then something will happen but 00:05:50
I also need a block for the 00:05:55
if so now I'm comparing if the 00:05:56
output that is the random number equals 00:05:59
thirteen 00:06:02
then what will happen will then output 00:06:03
number thirteen will be high and this 00:06:07
block will be here inside the first 00:06:09
if because if the input or the 00:06:12
one we are reading here is high 00:06:15
and the output is thirteen then number 00:06:17
thirteen will shine 00:06:20
so do you see this and 00:06:29
then if it generates for a random 00:06:31
number thirteen the same happens for twelve 00:06:33
eleven and ten so I will duplicate 00:06:37
the same code and put it again 00:06:40
in the subset 00:06:42
so the second if condition is inside 00:06:45
the first if condition 00:06:48
but now instead of comparing with thirteen 00:06:52
I'm going to compare with twelve and 00:06:54
now if output equals twelve twelve will 00:06:56
be high 00:06:58
then duplicate again for number eleven if 00:07:00
the output is eleven then eleven will 00:07:03
be high 00:07:05
and duplicate again for our last pin 00:07:09
for number ten 00:07:13
you see I almost put that in 00:07:18
the wrong place but this one has 00:07:19
to be connected to the others so 00:07:21
now if output equals ten number ten 00:07:23
is the one that's going to be 00:07:26
high all of them are here so 00:07:27
it means if I press the button 00:07:29
one of these possibilities will be true 00:07:31
one of these connectors will be high 00:07:33
and the LED connected to that number 00:07:35
will shine 00:07:38
but what happens if the input is 00:07:40
not high if i'm not pressing the 00:07:42
button you can probably guess that we 00:07:44
will have all four LED that 00:07:46
are low so these are under the 00:07:48
if not condition so let's add thirteen 00:07:51
twelve 00:07:56
eleven and ten 00:07:58
eleven 00:08:10
and ten so if I don't press 00:08:13
the button it means that this condition 00:08:15
is not true and it will go 00:08:17
to the if not condition and all 00:08:19
four will be low and the random 00:08:21
number has to be here connected to 00:08:23
these four blocks 00:08:25
so now everything has been programmed and 00:08:29
connected properly you see 00:08:31
so I can start the simulation 00:08:44
and if I click on the button 00:08:46
of course nothing happens because I am 00:08:48
not pressing the button but if I 00:08:52
am then one of them will shine 00:08:54
if I release they are off and 00:08:57
if I press again another one will 00:09:00
shine you can press it over and 00:09:02
over but we can't guess which one 00:09:04
is going to shine because 00:09:05
as we programmed it to be random 00:09:06
okay this is the circuit you will 00:09:09
now connect and program today good luck 00:09:11
Idioma/s:
en
Autor/es:
David Gonzalez Arroyo, Alyssa Fantel
Subido por:
David G.
Licencia:
Reconocimiento - No comercial - Compartir igual
Visualizaciones:
118
Fecha:
30 de enero de 2022 - 21:45
Visibilidad:
Público
Centro:
IES MARIE CURIE Loeches
Duración:
09′ 22″
Relación de aspecto:
1.78:1
Resolución:
1920x1080 píxeles
Tamaño:
105.44 MBytes

Del mismo autor…

Ver más del mismo autor


EducaMadrid, Plataforma Educativa de la Comunidad de Madrid

Plataforma Educativa EducaMadrid