Activa JavaScript para disfrutar de los vídeos de la Mediateca.
Arduino: LCD (I2C) - 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 are going
00:00:01
to learn how to use the LCD
00:00:03
screen and
00:00:06
we are going to connect it to the arduino board using
00:00:09
again a serial connection there are
00:00:12
serial connection with the computers but here
00:00:14
we're going to use a specific serial connection
00:00:16
and then we can find here ok
00:00:19
here
00:00:22
we can see the digital connectors we
00:00:24
already know then and if we moved
00:00:25
to the left we would find this
00:00:27
one that is called the SCL
00:00:29
and is one that is called the SDA
00:00:31
ok these two connectors
00:00:33
these two pins are used to
00:00:36
transmit serial information and we can use
00:00:39
them to send information to
00:00:42
different devices not just one, so
00:00:44
for example here we have the SCL
00:00:46
connection, the yellow wire and
00:00:48
here you can see that is connected
00:00:51
to the SCL connection to
00:00:52
the screen and here you
00:00:54
can see that the yellow wire continues
00:00:56
and goes to a new SCL
00:00:59
connection okay so the two of them
00:01:01
are using the same
00:01:03
wire the same connection and the same
00:01:04
for the SDA connection the
00:01:06
green wire
00:01:08
it is connected from the arduino board to
00:01:10
the first one and then to the
00:01:13
second okay and we also have two
00:01:15
other connectors ground
00:01:18
that is connected to ground obviously
00:01:21
the power source there and red green
00:01:24
and the red wire that is connected
00:01:27
okay five volts
00:01:30
and this is the way we connect
00:01:32
different
00:01:34
screens, LCD screens, to the computer
00:01:37
To the arduino board, I'm sorry. We can
00:01:39
connect several of them here we only
00:01:41
have connected two but if we had
00:01:43
a third one we would be able
00:01:45
to connect it the same way
00:01:47
okay just continuing the different wires
00:01:48
each LCD is going to be
00:01:52
defined
00:01:55
click on it we want to be
00:01:56
defined by the address, for example
00:01:58
this one, the address for the first one
00:02:00
is thirty four and the address for
00:02:02
the second one is thirty two ok
00:02:05
and there's another parameter here, that is
00:02:08
the protocol kind of language we're
00:02:10
going to use to program
00:02:14
our LCD screen ok we
00:02:16
use this protocol and the same
00:02:19
and it is the same for the two
00:02:23
of them okay different addresses but
same 00:02:25
same 00:02:25
protocol
and we need to use different 00:02:27
and we need to use different 00:02:27
addresses because using different addresses the arduino
00:02:30
board will be able to
00:02:32
to know to which one is speaking
00:02:34
or from which one is
00:02:37
receiving information okay
00:02:39
that's why we need different addresses okay
00:02:42
this is the way we connect different
00:02:45
devices. The LCD screen can be
00:02:48
found here if you type LCD here
00:02:51
there are two devices and the
00:02:54
one we use is the I2C
00:02:57
because I2C is the
00:02:59
serial protocol we are going to
00:03:01
use to connect it
00:03:02
eh ok so what about programming it
00:03:05
I want to open the block window
00:03:11
to make it bigger easier
00:03:16
to have a look at the codes. The first thing
00:03:20
we need to look at every code
00:03:22
every block we are going to use is in
00:03:25
the blue library because the arduino
00:03:26
I mean the LCD screen will
00:03:29
receive information from the arduino board
00:03:32
that's why we are using output blocks
00:03:34
all of them are blue and
00:03:36
here
00:03:40
because we have two screens we are going to
00:03:41
to set the two of them
00:03:44
and we are going to use this block
00:03:47
"configurar tipo de LCD"
00:03:49
for example, address thirty two
00:03:52
will be number one so thirty two
00:03:55
this one is meant to be
00:03:58
number one the lower
00:04:00
one
00:04:01
and
00:04:03
and the lower one is going to be
00:04:06
thirty four number two
00:04:08
okay and we use this protocol
00:04:11
the same protocol is here
00:04:14
because both of them
00:04:16
the LCD screen under the arduino
00:04:20
board, both of them they need
00:04:22
to speak the same language so number
00:04:24
one will use this language to communicate
00:04:26
with the arduino board is going to
00:04:28
be connected in address thirty two the
00:04:30
second one same protocol and thity four
00:04:33
so this way we can
00:04:35
we can connect several devices
00:04:38
there are addresses from thirty
00:04:41
two to thirty nine so we can
00:04:44
connect eight different devices using this protocol ok
00:04:45
and so be careful with addresses
00:04:52
ok they are very important
00:04:55
what other blocks do we have?
00:04:59
we have
00:05:02
this block
00:05:05
first of all, in LCD one or two or
00:05:12
three or four
00:05:15
we can do
00:05:17
different things for example we can switch
00:05:19
the light on you can erase the
00:05:23
screen, switch the light off what happens
00:05:25
if we switch
00:05:29
the light on for the first one
00:05:30
if we start the simulation
00:05:32
the first one is on but not the second one
00:05:37
and that's ok
00:05:39
we can change
00:05:42
we can switch the second one on
00:05:44
and we simulate it again
00:05:46
an now is number two is on
00:05:49
before
00:05:51
continuing with the blue blocks
00:05:54
I want you to realize that we are
00:05:57
using this kind of loop
00:05:59
not a real loop
00:06:02
"al iniciar"
00:06:03
this part of the program and this one
00:06:04
"siempre", forever, is a real
00:06:06
loop and not the first one. These are
00:06:08
the two parts of the program
00:06:11
in this new version of Tinkercad
00:06:13
these two blogs have been included this
00:06:18
one is the setup, "al iniciar" means
00:06:21
that they are going to
00:06:23
be run just once and then "siempre"
00:06:24
means
00:06:27
this is the real code i mean
00:06:28
the part of the program that will
00:06:29
be repeated again and again so
00:06:31
"al iniciar" we are using
00:06:33
these two blocks "configurar LCD"
00:06:35
here because we we only need to
00:06:37
set it up once and no more than that
00:06:39
and the rest of the code
00:06:42
that will be repeated again and again
00:06:44
is here, so
00:06:45
I'll go back to "siempre", forever, and for example
00:06:49
we can switch the light on
00:06:54
we can also erase the screen ok
00:06:57
we are going to erase the screen later
00:07:00
but for the moment we are going
00:07:01
to print a character for example we are
00:07:03
going to print, we are going to
00:07:06
switch number
00:07:08
one on just a light ok you
00:07:08
you can print things if the
00:07:10
screen is off for example
00:07:12
we are going to do it later, don' t worry
00:07:16
for the moment just with
00:07:18
the light on
00:07:19
let's go to print "hello world"
00:07:22
number one if you click start the
00:07:24
simulation
00:07:26
number one is
00:07:28
there's a problem, it is repeating again
00:07:32
and again and again "hello world"
00:07:34
"hello world", hello world"
00:07:35
how can we solve it?
00:07:38
we can solve it for example using "borrar pantalla"
00:07:39
but if we print and we erase
00:07:44
there's no time to see anything so
00:07:46
let's use a
00:07:48
"esperar"
00:07:49
so we will print "hello world"
00:07:53
we will wait for one second and
00:07:56
then the screen will be erased again
00:07:57
and we need a second "esperar"
00:08:00
because this way it will be
00:08:01
a kind of blink okay can you
00:08:03
imagine how will it work? "Hello World"
00:08:06
for one second then nothing for one
00:08:08
second
00:08:10
then we start again
00:08:11
Let's start the simulation
00:08:12
Can you see? It's a kind of blinking
00:08:20
This block, the first one, there's no
00:08:25
need to be the forever block
00:08:28
it can be here
00:08:31
this way the screen will be switched
00:08:33
on just once
00:08:35
In this code okay so
00:08:38
Let's start the simulation again and you will
00:08:40
see that it works the same way
00:08:42
Hello world
00:08:45
nothing
00:08:47
now I want you to see that
00:08:52
switching the light on
00:08:53
doesn't mean
00:08:57
that this one will not work
00:08:58
there is no light but we
00:09:04
can see the code so
00:09:06
okay but there are more instructions to
00:09:12
take into account this one is really
00:09:15
really interesting, it means
00:09:17
"establecer posicion", position means where we
00:09:20
want to
00:09:23
to print the character for example
00:09:26
imagine we want to print the character
00:09:29
in position number
00:09:31
well, first of all
00:09:34
there are columns arrows every every every
00:09:36
LCD
00:09:41
I'll run the simulation, it will be easier with light
00:09:43
there is a first row
00:09:54
there's a second row
00:09:59
and there are columns this is the
00:10:01
room number zero this is raw number
00:10:05
one
00:10:07
this is column numbers zero, one, two, three
00:10:09
four, until fifteen okay so with this
00:10:12
block, "establecer posición"
00:10:17
we can decide where we want to print
00:10:19
for example imagine want to print in
00:10:23
first raw, number zero,
00:10:26
position the middle more or less number
00:10:30
eight instead of typing "hello world" we will to
00:10:33
type something like that
00:10:36
let's have a look
00:10:40
It is printed there in the middle of the position
00:10:45
we can change position for example instead
00:10:49
of number row I mean column eight
00:10:51
we can chose column four
00:10:54
and instead of using raw zero we can use row one
00:10:57
Now the position is different
00:11:04
raw number one, remember this one the upper one
00:11:08
is zero and the other one is one
00:11:10
position zero one two three and four
00:11:12
so we can decide where we want
00:11:15
to print things okay
00:11:17
very very important defining the different addresses
00:11:25
for everyone
00:11:28
we can print in different LCD
00:11:33
for example I'm going to duplicate this block
00:11:36
on this part
00:11:39
I want
00:11:44
the program number two two and I'm going to
00:11:45
program it in number twelve
00:11:48
raw number zero
00:11:53
i'm going to print it
00:11:56
in number two instead of
00:11:58
using
00:12:01
this one. I'm going to use the slash
00:12:03
I'm going to erase them too ok this way
00:12:06
you can to see that we can
00:12:09
program different screens at the same time
00:12:10
because they have different addresses
00:12:13
Let's have a look. So we will have two different
00:12:15
blinkings one for the first one the
00:12:18
first one for the upper
00:12:20
here this character, here the second character
00:12:24
I can also
00:12:29
I can also switch the light on for the
00:12:31
second one
00:12:35
okay
00:12:37
and let's start the program again
00:12:39
easier to see if the light is on
00:12:43
so we have these different instructions
00:12:47
"configurar"
00:12:51
to define the program, the language, the code we are going to use
00:12:53
we are going to use this one, so don't change it
00:12:57
and the addresses we are going to use
00:13:00
every screen will have a different address
00:13:03
we also have this block, the LCD "activar luz de fondo"
00:13:07
we can
00:13:12
erase the screen there are other possibilities
00:13:14
but from the moment we are going
00:13:16
to use just this one "activar luz de fondo"
00:13:17
or switch it on and switch it off
00:13:21
or "borrar la pantalla", erase the screen
00:13:24
we also have "establecer
00:13:26
posición" means define where you want to
00:13:30
print
00:13:33
to define the position you want to print okay
00:13:33
and here "imprimir" means you are going to
00:13:36
write something on this position
00:13:38
the one you have already defined really
00:13:41
really easy using these screens connecting them
00:13:44
and you only have three or four
00:13:47
types of blocks okay four types
00:13:49
of blocks, nothing more than that
00:13:52
okay so the exercise for you is
00:13:53
is not going to be difficult, you will have to
00:13:55
repeat
00:13:58
again we will have two screens
00:14:00
start simulation
00:14:05
and they will behave this way
00:14:07
okay
00:14:10
so
00:14:12
it's not difficult just kind of blinking
00:14:14
but with different positions, first position
00:14:17
second position, third position, fourth position
00:14:19
the first two positions in
00:14:22
the upper LCD screen and the two
00:14:25
following positions in the lower LCD screen
00:14:28
okay if you have understood
00:14:32
the example. Programming it it's really easy
00:14:34
so that's all
00:14:39
all you need to know
00:14:43
- Idioma/s:
- Autor/es:
- David Gonzalez Arroyo
- Subido por:
- David G.
- Licencia:
- Reconocimiento - No comercial - Compartir igual
- Visualizaciones:
- 159
- Fecha:
- 17 de julio de 2022 - 12:40
- Visibilidad:
- Público
- Centro:
- IES MARIE CURIE Loeches
- Duración:
- 14′ 47″
- Relación de aspecto:
- 16:10 El estándar usado por los portátiles de 15,4" y algunos otros, es ancho como el 16:9.
- Resolución:
- 1152x720 píxeles
- Tamaño:
- 30.86 MBytes