This Circuit expands on the Buzzers versatility by introducing Push-Buttons to control when notes are played.

Transcript

Hey guys, Christian here from Core electronics. Today we're going to get started with circuit 2B, the digital trumpet from project Set 2.

So, project set 2 focuses, on the use of sound and the use of a piezo buzzer in Arduino projects. So, from circuit 2A, we're not going to change all that much, so you can leave the setup the same and any tinkering that must be done will go through. So, in this circuit we'll be using a push button, now push buttons a new component, that will allow us to connect rails of the breadboard to one another. So just looking at it we have four pins on the push button and we're going to connect them so that the isolating strip runs down the middle of it. So, make sure that we place them closer together. So that once again for circuit 2C, we can keep the board relatively the same.

So, it's important to note here, that the row 30 that we've got here, row 30 will be connected the whole way across, as these two pins of the push button are connected, similarly rows 28 will be connected and rows 24, 22 and so on will also be connected. Now when we press the button what happens internally, is the connections between these two pins are brought together. So, when I do this, rows 28 and rows 30 will be internally connected or electrically connected. So, this is not a good thing if we're connecting the power directly to ground, so what we must do is, we must define a new input. So, this input will be called input pull-up and that is the use of a pull-up resistor, within the Redboard. Now a pull up resistor keeps the input to a high state, until it is connected to a low state. So, it will connect one of these pins from each push button to a pin that is configured to be input pull up and then we'll connect the other pin to a ground value.

Now the reason that we can do this is because of the resistance value, the voltage drop across the resistor will be sufficient enough. So that the circuit doesn't short-circuit or break so connecting them as shown in the diagram. We will go 28 to the ground rail, we will go 22 to the ground rail, we will go 16 to the ground rail. Now notice that our ground rail isn't connected to anything. So, we will have to form another connection there, from the ground supply. So, we can connect the negative lead from the potentiometer, to the ground rail and we can connect something from ground to the ground rail, so they are now all connected to a ground voltage. So, we will use the red lead to connect the other pin to pin 2, then we will use the yellow pin to connect the other pin of the yellow push-button to pin 3 and the green one similarly to pin 4. Now what we have here is a circuit arrangement that has not pull-up resistors in it yet, as we haven't designed that but once we connect it and we move on to our Arduino IDE and the sketch, will be able to show you exactly what's going on.

So, here to be digital trumpet, we'll open that up and in here we will have the first pin, which is our red one connected to 2, a second one, a yellow one connected 3 and our green one connected to 4. The buzzer pin here stays the same, as specified earlier and now here is where it gets interesting this is where we define the actual pull-up resistor. So, if we looked at buzzer pin here, we can see that normally we use output or if we wanted our buzzer pin to be an input, we write input, but for our input pull-up resistors, we must use the input pull-up declaration. So, we cope in mode first key pin red, second key pin yellow and third key pin green to be configured in an input pull-up fashion. So, this means that when we're checking the state of these buttons, we are trying to compare the digital read of the button and if that is a "LOW", then we know that the button has been pressed as the "HIGH" connection which it's normally it has been dropped to the ground connection or to a low potential. So, in the event of this, "if this" we will do what is in these brackets and that is to play a tone of 262 Hertz on the buzzer pin. "else if", the yellow push button is selected, and it is read to be "LOW", it'll play 330 Hertz. "else if", digital read the green push button is read as "LOW", it'll play 392 Hertz and if no buttons are selected, it will turn off all noises currently on the buzzer pin.

So here they've given a reference, so if we want to change any of these frequencies we can do so. So, the first one is a C, the second one's an E and the third one is a G. So, if we wanted to change these and make a different C, we could put that on there but for these purposes we'll just run these ones. So, we'll upload this current to the board and we shall see that the input pull-up doesn't short the circuit and now it's done uploading. So, we can press the green one, and don't forget we can change this potentiometer to change the current. So, I'm going to put it on max volume and we can change this, while pressing the button. Notice that each section works from here, so we are looking at this pin, it works and then else, it is quietening the buzzer, yellow and green.

So, that there is how we use pull-up resistors to control buttons and how we use "if else" statements and digital read comparisons, to let the Arduino board know or the Redboard know that we want to do something else.

So that there is circuit 2C, the digital trumpet. Follow us in our next video for circuit 2C.

Catch you later.

Feedback

Please continue if you would like to leave feedback for any of these topics:

  • Website features/issues
  • Content errors/improvements
  • Missing products/categories
  • Product assignments to categories
  • Search results relevance

For all other inquiries (orders status, stock levels, etc), please contact our support team for quick assistance.

Note: click continue and a draft email will be opened to edit. If you don't have an email client on your device, then send a message via the chat icon on the bottom left of our website.

Makers love reviews as much as you do, please follow this link to review the products you have purchased.