NOTE: YOU MUST PROGRAM AND DEPLOY THE BUZZER IN NODE RED BEFORE YOU CONNECT THE BUZZER TO THE PI OTHERWISE THE BUZZER WILL OVER HEAT
Setting up the button and the buzzer is much the same as in their standalone tutorials, the major difference here is that we’re going to have the button linked up to the buzzer instead of a debug node.
First you’ll need a GPIO Input, and output node.
Just like the push-button tutorial we’ll configure the input node to read the button.
Double click on the Raspberry Pi input node to open its configuration menu.
Set the Pin to GPIO24. Set Resistor? to pulldown. You can Name the node anything, I chose “button”.
Before moving on you can verify that your button works by using a debug node
Make sure you hit deploy whenever you’ve made any changes, or nothing will happen.
Next we’ll setup the GPIO node for the buzzer.
These are the same settings as in the standalone buzzer tutorial, except we’re using a different pin to control the buzzer.
PWM output means we’ll be sending the buzzer a pulsing signal that peaks 100 times a second, instead of just holding the pin at 3v.
Finally we just have to connect the nodes together
Make sure you deploy first, but as long as both the nodes are setup correctly and the wiring is correct the buzzer should buzz whenever you press the button!
Connections for the button:
- VCC -> 3.3V
- OUT -> 18#24
- GND -> GND
Connections for the buzzer:
- VCC -> 3.3v
- I/O -> PIN36 #16
- GND -> GND
Using this flow as a base we can explore several possibilities
- How can we change how the buzzer sounds, what kind of frequency is it buzzing at?
- Can we use this same flow to activate a RGB LED instead of a buzzer?
- What kinds of input device could we use other than a push-button to activate the buzzer?
- What else could we output too that isn’t a buzzer, how about something purely digital.