Sound Sensitive LED Lights Using Raspberry Pi Pico
by just_another_person in Circuits > Raspberry Pi
890 Views, 6 Favorites, 0 Comments
Sound Sensitive LED Lights Using Raspberry Pi Pico
This tutorial will be teaching you how to make a sound-sensitive LED controlled by Raspberry Pi Pico.
This is one of the more basic circuits using Pico, and a great starter project to get comfortable with the software. In this tutorial I'll go into more depth explaining the code and circuitry so it's pretty beginner friendly, and once you build it you can also go a step further and add various modifications (e.g. multiple lights, buzzers, switches).
Supplies
Add Pico to Breadboard
Attach Pico to the top of the breadboard, and use the diagram above to reference the pinouts as we progress with the circuit.
Connect Sound Sensor
The sound sensor has three different pins that require connection:
OUT (output)-- connected to pin 1 (GP0)
GND (ground)-- connect to any one of the ground pins on Pico. For this one I used pin 33.
VCC (power source)-- Pin 36- 3V3(OUT)
Reference the image above to see how the finished connections should look.
Connect LED
Connect the long leg of the LED to GP16 (pin 21 of pico), and the other leg to the negative rail. Then, connect one leg of your resistor to the negative rail and the other to the positive. Connect the resistor to ground by extending the male-male jumper wire from the positive rail to pin 38 (ground).
Code
Reference the picture above for the code
I wrote this code in Thonny and then ran it by connecting it to Raspberry Pi pico.
Basically what we're doing here is running a 'while true' loop, where if the sound sensor outputs an analog value of '1', meaning that it has detected a sound, the LED will turn on. Otherwise if the outputted value is 0, then the LED turns off.
The print statements in the code are not necessary, although they are helpful for trouble shooting or trying to find mistakes in the code and connections.
Trouble Shooting: Calibrate Sensor
In a quiet environment, use your screwdriver to turn the potentiometer until the small red LED on the sensor turns on. Test the sensor by speaking near it, and if it is properly calibrated then the main LED should turn on with your voice.
Modifications
Here are some more ideas to go a step ahead and modify the project:
a) add a buzzer-- use the same connections as the LED, and connect the long leg to pico and the short leg to power rail on the breadboard. The resistor is unnecessary for this.
b) add a switch to turn the circuit on and off
c) add more LEDs!