Activa JavaScript para disfrutar de los vídeos de la Mediateca.
Arduino: serial II (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. In this exercise we're going
00:00:00
to continue studying how the computer can
00:00:07
send and receive information from the arduino
00:00:09
board here on the screen you can
00:00:12
see the circuit we're going to use
00:00:14
we have four LED connected to the
00:00:16
usual connectors
00:00:19
thirteen twelve eleven and ten we are
00:00:20
going to use digital outputs and every
00:00:23
LED is connected to a two hundred
00:00:25
twenty ohms protection resistor so nothing new
00:00:27
for the moment we've done that before
00:00:32
let's go to the code and have
00:00:34
a look
00:00:36
this block here read serial monitor is
00:00:38
a new one this is the purple
00:00:43
block which means it's from the input
00:00:45
library and it means that the arduino
00:00:47
board is reading from the serial connection
00:00:50
from the wire that is connected from
00:00:52
the usb that is connected to the
00:00:54
computer
00:00:56
so we will have a variable that
00:00:58
is called
00:01:00
serial, "serie", because I just want
00:01:02
to choose a clear name so we
00:01:06
take the value or the number from
00:01:08
the usb wire and we store it
00:01:09
inside the variable and now I'm going
00:01:12
to use this variable to control the
00:01:15
arduino board here for instance as an
00:01:17
example if this variable
00:01:20
equals one then thirteen will be high
00:01:22
so it means that the red LED
00:01:26
will shine so let's have a look
00:01:28
and start the simulation
00:01:30
nothing happens while remember that the serial
00:01:35
monitor is down here and to send
00:01:37
variables with a number we have to
00:01:39
type down here in this box
00:01:41
so if I type one and I
00:01:44
press enter
00:01:46
nothing happens because there's a problem
00:01:48
this block is not the right one
00:01:52
if you want to read integral numbers
00:01:54
there's a problem with the
00:01:55
simulation but it's not a big problem
00:01:57
we can solve it by changing from
00:02:00
blocks to text
00:02:02
now notice that when we want to
00:02:07
change from blocks to code we will
00:02:08
not be able to come back to
00:02:11
the blocks so when we change we
00:02:12
just have to be certain that that's
00:02:14
what we want but if it is
00:02:16
we click continue
00:02:18
and then here we will have our
00:02:24
code
00:02:26
so right here this is the function
00:02:31
we are using to read serial equals
00:02:34
this function so here instead of using
00:02:37
serial read we are going to use
00:02:40
a new function and type in it's
00:02:42
called serial
00:02:46
parse int
00:02:48
if you have any problem just typing
00:02:51
in here try it a second or
00:02:53
a third time because sometimes you can't
00:02:55
get it to work the first time
00:02:57
for some reason so keep trying
00:02:58
so here we have the new code
00:03:03
I have only changed the function we
00:03:05
using to read the number and now
00:03:07
I'm going to start the simulation again
00:03:09
and now if I send number one
00:03:13
down here
00:03:14
the LED shines
00:03:18
okay that seems really simple so your
00:03:20
exercise is a little bit more complicated
00:03:23
than this one you will repeat the
00:03:26
code remember you can stop the video
00:03:28
and go back if you need you
00:03:31
will read the variable the same way
00:03:33
and you will add several blocks for
00:03:35
switching all of them on individually
00:03:37
you will have four numbers to switch
00:03:41
them on and all four numbers again
00:03:42
to switch them off
00:03:45
remember that the serial monitor is here
00:03:49
okay
00:03:53
down here so for example you can
00:03:59
use one two three and four to
00:04:01
switch them on
00:04:06
and then maybe you can use five
00:04:08
six seven and eight to turn them
00:04:10
off whatever you want these are the
00:04:12
orders that you're sending through the usb
00:04:15
if you can instead of repeating the
00:04:18
blocks you can just copy and paste
00:04:20
this part here
00:04:23
this is the part that you can
00:04:26
duplicate to reproduce the different possibilities
00:04:27
thirteen is the number of the connector
00:04:32
here instead of high you can use
00:04:34
low and one here means the number
00:04:37
of the code we use to send
00:04:40
information so you can copy and paste
00:04:42
this part of the code if you
00:04:44
want to
00:04:45
you will have to go back to
00:04:47
the blocks program a new circuit and
00:04:48
then create a new code or you
00:04:51
can copy and paste this part however
00:04:53
many times you want
00:04:55
but before I finish I want to
00:04:58
show you the exercise in real life
00:04:59
so here I have copied and pasted
00:05:02
my code and I'm going to upload
00:05:04
it to the computer and check that
00:05:06
everything is correct
00:05:07
so upload okay everything works now I
00:05:10
upload it to the arduino board it's
00:05:14
uploaded and I go to the serial
00:05:17
monitor here so I'm going to send
00:05:19
my commands
00:05:22
the first one is thirteen just cause
00:05:24
I'll start with that one
00:05:27
and the first ltd is shining what
00:05:30
happens if I type twelve
00:05:33
now the green one is shining and
00:05:37
if I type eleven
00:05:39
the yellow one shines now if I
00:05:43
type one hundred and thirteen
00:05:46
the red one turns off
00:05:51
one hundred and twelve
00:05:53
the green ones off and one hundred
00:05:57
and eleven
00:06:00
the yellow one is off so the
00:06:02
interesting thing about this here is that
00:06:04
I can control the arduino board from
00:06:06
my keyboard this is the most amazing
00:06:08
thing the point of this and you
00:06:10
can see that it works in real
00:06:12
life so you will have to do
00:06:13
something like this programming orders to switch
00:06:15
all the LED on and then to
00:06:18
switch all of them off
00:06:20
if you have understood the exercise with
00:06:22
one LED switching it on
00:06:24
then you should be able to have
00:06:26
enough information to replicate and finish the
00:06:28
rest of the exercise okay good luck
00:06:30
- Idioma/s:
- Autor/es:
- David Gonzalez Arroyo, Alyssa Fantel
- Subido por:
- David G.
- Licencia:
- Reconocimiento - No comercial - Compartir igual
- Visualizaciones:
- 49
- Fecha:
- 20 de marzo de 2022 - 19:09
- Visibilidad:
- Público
- Centro:
- IES MARIE CURIE Loeches
- Duración:
- 06′ 35″
- Relación de aspecto:
- 1.78:1
- Resolución:
- 1920x1080 píxeles
- Tamaño:
- 67.05 MBytes