Activa JavaScript para disfrutar de los vídeos de la Mediateca.
Arduino: LCD (I2C) (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 are going to learn how to use the LCD screen, and we are going to
00:00:00
connect it to the Arduino board using again a serial connection. There are serial connections
00:00:07
with the computers, but here we're going to use a specific serial connection. And then we can find
00:00:12
here. Here we can see the digital connectors we already know, then, and if we move to the left,
00:00:19
we would find this one that is called the SCL and one that is called the SDA.
00:00:25
These two connectors, these two pins, are used to transmit serial information and we can use
00:00:31
them to send information to different devices, not just one. So, for example, here we have the SCL
00:00:37
connection, the yellow wire, and here you can see that it is connected to the SCL connection to the
00:00:45
screen. And here you can see that the yellow wire continues and goes to a new SCL connection.
00:00:50
So the two of them are using the same wire, the same connection, and the same for the SDA
00:00:57
connection, the green wire. It is connected from the Arduino board to the first one and then to
00:01:03
the second one. And we also have two other connectors. Ground, that is connected to ground,
00:01:09
obviously, and the power source there, and the red wire that is connected to 5 volts.
00:01:24
This is the way we connect different screens, LCD screens, to the Arduino board. We can connect
00:01:30
several of them. Here we only have connected two. But if we had a third one, we would be able to
00:01:37
connect it the same way. Just continuing the different wires. Each LCD is going to be defined.
00:01:47
Click on it. We want to be defined by the address. For example, this one, the address for the first
00:01:55
one is 34 and the address for the second one is 32. And there's another parameter here,
00:02:03
which is the protocol kind of language we're going to use to program our LCD screen.
00:02:10
We use this protocol and the same, and it is the same for the two of them.
00:02:15
different addresses but the same protocol. We need to use different addresses because using
00:02:20
different addresses, the Arduino board will be able to know to which one it is speaking or from
00:02:26
which one it is receiving information. That's why we need different addresses. This is the way we
00:02:32
connect different devices. The LCD screen can be found here. If you type LCD here, there are two
00:02:39
devices, and the one we use is the I2C, because I2C is the serial protocol we are going to use
00:02:54
to connect it. So, what about programming it? I want to open the block window to make it bigger
00:03:00
and easier to have a look at the codes. The first thing we need to look at every code,
00:03:19
every block we are going to use, is in the blue library, because the Arduino, I mean,
00:03:25
the LCD screen will receive information from the Arduino board. That's why we are using output
00:03:30
blocks. All of them are blue. Here, because we have two screens, we are going to set the two of
00:03:37
them, and we are going to use this block, configure our typo to LCD. For example, address 32 will be
00:03:44
number 1, so 32, this 1 is meant to be number 1, the lower 1, and the lower 1 is going to be 34.
00:03:52
number 2. And we use this protocol, the same protocol is here, because both of them,
00:04:08
the LCD screen and the Arduino board, both of them need to speak the same language.
00:04:15
So number 1 will use this language to communicate with the Arduino board.
00:04:26
It's going to be connected in address 32. The second one, same protocol and 34.
00:04:31
So this way we can connect several devices. There are addresses from 32 to 39. So we can
00:04:38
connect 8 different devices using this protocol. And so be careful with addresses, they are very
00:04:46
important. What other blocks do we have? We have this block. First of all, in LCD 1, or 2, or 3,
00:04:53
or 4, we can do different things. For example, we can switch the light on, we can erase the screen,
00:05:17
switch the light off. What happens if we switch the light on for the first one?
00:05:24
If we start the simulation, the first one is on, but not the second one, and that's okay.
00:05:36
We can change, we can switch the second one on, and we simulate it again. And now number 2 is on.
00:05:42
Before continuing with the blue blocks, I want you to realize that we are using this kind of loop.
00:05:50
Not a real loop, "Al iniciar". This part of the program, and this one, "siempre", forever,
00:05:57
is a real loop and not the first one. These are the two parts of the program.
00:06:09
In this new version of Tinkercad, these two blocks have been included.
00:06:15
This one is the setup. "Al iniciar" means that they are going to be run just once.
00:06:20
and then "siempre" means this is the real code. I mean, the part of the program that will be
00:06:25
repeated again and again. So "Al iniciar", we are using these two blocks, configure our LCD here,
00:06:31
because we only need to set it up once and no more than that. And the rest of the code that
00:06:39
will be repeated again and again is here. So I'll go back to "siempre", forever, and for example,
00:06:44
we can switch the light on. We can also erase the screen. We are going to erase the screen later
00:06:51
but for the moment we are going to print a character. For example we are going to print
00:06:58
we are going to switch number one on just a light. You can print things if the screen is off.
00:07:04
For example we are going to do it later don't worry. For the moment just with the light on
00:07:11
let's go to print hello world number one. If you click start the simulation, number one is,
00:07:18
there's a problem, it is repeating again and again and again hello world, hello world,
00:07:25
hello world. How can we solve it? We can solve it, for example, using boropantala,
00:07:31
but if we print and we erase, there's no time to see anything. So let's use a espra.
00:07:44
So we will print hello world, we will wait for 1 second, and then the screen will be erased again.
00:07:49
And we need a second, Espera, because this way it will be a kind of blink.
00:07:58
Can you imagine how will it work?
00:08:03
Hello world, for 1 second, then nothing for 1 second, then we start again.
00:08:06
Let's start the simulation.
00:08:12
Can you see?
00:08:15
It's a kind of blinking.
00:08:16
This block, the first one.
00:08:18
There's no need to be the forever block, it can be here. This way the screen will be switched on
00:08:28
just once in this code. So let's start the simulation again, and you will see that it
00:08:34
works the same way. Hello world, nothing. Now, I want you to see that switching the light on
00:08:40
doesn't mean that this one will not work. There is no light, but we can see the code.
00:08:54
So, but there are more instructions to take into account.
00:09:26
This one is really, really interesting.
00:09:30
It means, establish a position.
00:09:34
Position means where we want to print the character.
00:09:37
For example, imagine we want to print the character in position number,
00:09:40
well, first of all, there are columns and rows.
00:09:44
Every LCD.
00:09:48
I'll run the simulation, it will be easier with light.
00:09:50
There is a first row, there's a second row, and there are columns. This is the row number 0.
00:09:53
This is row number 1. This is column number 0, 1, 2, 3, 4, until 15. So, with this block,
00:10:07
establish a position, we can decide where we want to print. For example, imagine we want to print
00:10:18
in the first row, number 0, position the middle, more or less number 8. Instead of typing,
00:10:24
hello world, we will type something like that. Let's have a look. It is printed there in the
00:10:31
middle of the position. We can change position, for example, instead of number row, I mean column
00:10:38
8, we can choose column 4. And instead of using row 0, we can use row 1. Now the position is
00:10:45
different. Row number 1, remember this one, the upper one is 0 and the other one is 1.
00:10:53
Position 0, 1, 2, 3, and 4. So we can decide where we want to print things.
00:11:01
Very, very important defining the different addresses for everyone.
00:11:09
We can print in different LCDs. For example, I'm going to duplicate this block on this part.
00:11:13
I want the program number 2, and I'm going to program it in number 12, row number 0.
00:11:40
I'm going to print it in number 2.
00:11:47
Instead of using this one, I'm going to use the slash.
00:11:50
I'm going to erase them too.
00:11:54
This way you can see that we can program different screens at the same time, because they have different addresses.
00:11:57
Let's have a look.
00:12:03
so we will have two different blinkings one for the first one the first one for the upper
00:12:05
here this character here the second character i can also switch the light on for the second one
00:12:10
and let's start the program again easier to see if the light is on so we have these different
00:12:33
instructions configure our to define the program the language the code we are going to use we are
00:12:41
going to use this one, so don't change it. And the addresses we are going to use, every screen
00:12:52
will have a different address. We also have this block, the LCD, Active or Lose Defondo.
00:13:01
We can erase the screen. There are other possibilities, but for the moment we are
00:13:12
going to use just this one, Active or Lose Defondo, or switch it on and switch it off,
00:13:18
or Bora La Pantala, erase the screen. We also have, establish a position, means define where
00:13:23
you want to print, to define the position you want to print. And here, imprimir, means you are
00:13:30
going to write something on this position, the one you have already defined. Really, really easy
00:13:39
using these screens, connecting them, and you only have three or four types of blocks. Four types of
00:13:45
blocks, nothing more than that. So the exercise for you is not going to be difficult. You will
00:13:52
have to repeat. Again, we will have two screens. Start simulation, and they will behave this way.
00:14:07
So it's not difficult, just kind of blinking, but with different positions.
00:14:16
First position, second position, third position, fourth position. The first two positions in the
00:14:21
upper LCD screen and the two following positions in the lower LCD screen. If you have understood
00:14:28
the example, programming it, it's really easy. So that's all. All you need to know.
00:14:35
- Idioma/s:
- Materias:
- Tecnología
- Etiquetas:
- Arduino
- Niveles educativos:
- ▼ Mostrar / ocultar niveles
- Educación Secundaria Obligatoria
- Ordinaria
- Primer Ciclo
- Primer Curso
- Segundo Curso
- Segundo Ciclo
- Tercer Curso
- Cuarto Curso
- Diversificacion Curricular 1
- Diversificacion Curricular 2
- Primer Ciclo
- Compensatoria
- Ordinaria
- Autor/es:
- David González Arroyo
- Subido por:
- David G.
- Licencia:
- Reconocimiento - No comercial - Compartir igual
- Visualizaciones:
- 25
- Fecha:
- 24 de diciembre de 2024 - 15:13
- Visibilidad:
- Público
- Centro:
- IES MARIE CURIE Loeches
- Duración:
- 14′ 47″
- Relación de aspecto:
- 1.78:1
- Resolución:
- 1920x1080 píxeles
- Tamaño:
- 159.68 MBytes