Combine the use of Raspberry Pi input and output nodes in Node-Red to control an LED or buzzer with a push button.
What You Will Learn:
- Basic Circuit Prototyping
- Basic Node-Red Programming
What You Need to Know:
- RPi Node-Red: Push Button Tutorial
- RPi Node-Red: LED Tutorial
- RPi Node-Red: Piezoelectric Buzzer Tutorial
- At Least 1 LED
- At Least 1 Resistor
- Piezoelectric Buzzer
- Some Jumper Wires
- Needle Nose Pliers
Setting up the Hardware
This wiring diagram is simply the combination of the individual LED, buzzer, and push button circuits. Make sure that the LED has a resistor on it. Wire a pin on the buzzer to GPIO16, wire the positive leg of the LED to GPIO12, and wire one of the pins on the button to GPIO25. You can wire all the grounds to a rail and then to the GPIO GND or the connections can be made individually.
If it is difficult to put the components into the breadboard without the legs bending try and use needle nose pliers to help push the pins in.
Setting up Node-Red
Start Node-Red and navigate to 127.0.0.1:1880. Drag one Raspberry Pi input node and two Raspberry Pi output nodes into the flow area.
Double click the Raspberry Pi input node to open its configuration menu. Set the Pin to GPIO25. Set Resistor? to pulldown. I set the Name to “button”.
Double click one of the Raspberry Pi output nodes to open its configuration menu. This will be the LED so set the Pin to GPIO12. Leave Type set to Digital output, Initialise the pin state to low. Name the node “LED”
Double click the other Raspberry Pi output node to open it’s configuration menu. Set Pin to GPIO16. Set Type to PWM output. Set Frequency to 100. Name the node “buzzer”.
Wire each output node to the single input node and deploy the flow.
If everything works properly activating the button should turn on the LED and activate the buzzer. To stop either output node from activating just remove its connection to the button node and redeploy the flow.
- What other combinations can you make with the items in your kit?