Activa JavaScript para disfrutar de los vídeos de la Mediateca.
Arduino: buzzer - 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 video tutorial we are going to learn how to use a buzzer. A buzzer or a beeper,
00:00:00
as you can see on the screen, is a device that produces sound. So the first thing we need to
00:00:07
know is that there is a buzzer here in the library of components. In Spanish we say piezo or piezo
00:00:14
electrical so just click and drag you can use the proto board we are going to use the arduino board
00:00:21
and connecting the big part to the or the buzzer to the arduino board is really really really easy
00:00:30
one of the connectors is going to be connected to the ground and the other one to
00:00:37
whatever digital pin we want for instance here the buzzer has been connected to 12.
00:00:43
Okay, this is the connection. Really, really easy. Programming is not really difficult either.
00:00:50
We have a look at the code. This is the simplest way of programming the buzzer. We have used
00:00:57
one blue block. Remember, the blue library is the output. We use the reproducir altavoz and
00:01:04
el pasador. Pasador means connector here. We're going to connect. We have connected it to 12.
00:01:11
Tono is the frequency, here it's going to be 50 Hz, and it's going to sound for half a second.
00:01:16
And we will wait for one second before we start again.
00:01:27
Be careful, because sounding for half a second and waiting one second,
00:01:31
it doesn't mean that the whole program will last one and a half seconds,
00:01:38
because it works a little bit different.
00:01:43
The moment we start the sound, we start the waiting tool.
00:01:45
Do you understand?
00:01:51
So it means that while we are waiting, there is also sound.
00:01:51
So here it means that we are going to be waiting for one second,
00:01:56
but during this one second, half of this one second is going to be sound.
00:02:01
So here we have a square wave, una onda cuadrada.
00:02:08
half of the second is going to be is going to be sound the other one the one
00:02:11
that the second half of the second there will be no sound because we are waiting
00:02:17
that the second finishes do you understand the idea so on what happens
00:02:22
if we start the simulation if we start simulation this is the sound okay now
00:02:27
let's change the frequency instead of having 50 we are going to have 100 what
00:02:35
happens if I start the simulation now it sounds different because the frequency
00:02:42
is higher now let's try another possibility instead of producing sound
00:02:50
for 0.5 seconds, we are going to produce sound for 0.7 seconds, okay? It means 70% of the time
00:02:58
there will be sound during the 70% of the time we are waiting. You understand the idea? So let's
00:03:08
produce the sound again. Can you hear the period of time? While there is no sound, it's shorter
00:03:15
than before there is sound for 0.7 there is no sound for 0.3 30 seconds okay okay this is the
00:03:27
simplest way of programming a beeper but we are going to program it a little bit more we are going
00:03:36
to make a program we are going to do a program a little bit more complicated we are going to
00:03:43
program it this way using a different loop and you see contar this is the loop this is the program
00:03:47
We already have the reproducer altavoz and the weight and it will be
00:03:54
inside a loop. Contar arriba. Two possibilities. Arriba
00:03:58
abajo. Arriba means counting upwards or counting downwards.
00:04:04
It means we are going to move upwards or downwards.
00:04:09
Okay, let's start here.
00:04:14
It means, well, first thing we need is a variable. The name for this
00:04:17
variable is tono, just because I want. It could be frequency or whatever.
00:04:20
So it means that with this variable we are controlling the frequency.
00:04:24
We are going to sweep frequencies from 10 Hz to 130 Hz.
00:04:29
Each time we will step 10 units. We will move upwards.
00:04:37
I'm going to show it using the example.
00:04:43
First frequency, 10 Hz. Second one, 10 plus 20, 30.
00:04:46
Third one, 30 plus 20, 50.
00:04:52
Next one, 70, 90, 110, and 130, the last one.
00:04:55
It means that each time we jump, or each time we add, we add 20 units.
00:05:01
This is the meaning of 20, this is the meaning of 10, this is the meaning of 130, the final value.
00:05:07
Here we have the variable we are using to store the numbers,
00:05:12
and here having upwards, having arriba, it means that we are going to move
00:05:15
10, 30, 50, 70, 90, 100, 10, 130.
00:05:22
We could move hacia abajo, downwards, but this way we will start here,
00:05:27
130, and we will finish at 10, 130, 110, 90, 70, 50, 30, and 10.
00:05:33
Do you understand? I think now you understand all the variables,
00:05:39
or the numbers or the possibilities here in this loop.
00:05:43
And this loop is here, okay?
00:05:48
I mean, this is the main program,
00:05:49
the one we had in the previous example
00:05:51
that is now inside the variable, inside the loop.
00:05:53
So let's start the simulation.
00:05:57
And we start again.
00:06:10
So there is a full loop,
00:06:12
and when the loop ends, we start again, okay?
00:06:13
So the second one is the one we have to reproduce,
00:06:16
and there will be also two more questions.
00:06:19
So, good luck!
00:06:22
- Autor/es:
- David Gonzalez Arroyo
- Subido por:
- David G.
- Licencia:
- Reconocimiento - No comercial - Compartir igual
- Visualizaciones:
- 229
- Fecha:
- 10 de enero de 2021 - 18:30
- Visibilidad:
- Público
- Centro:
- IES MARIE CURIE Loeches
- Duración:
- 06′ 25″
- Relación de aspecto:
- 1.78:1
- Resolución:
- 1920x1080 píxeles
- Tamaño:
- 19.55 MBytes