Sound Sensitive LED Lights Using Raspberry Pi Pico

by just_another_person in Circuits > Raspberry Pi

497 Views, 5 Favorites, 0 Comments

Sound Sensitive LED Lights Using Raspberry Pi Pico

Sound Sensor with LED- finished
IMG_6607.jpeg

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

IMG_6565.jpeg

-1x male-male jumper wire (amazon)

-3x male-female jumper wires (amazon)

-1x LED (any color) (amazon)

-1x Raspberry Pi Pico + USB cable (amazon)

-1x 220 ohm resistor (amazon)

-1x sound sensor (amazon)

-1x breadboard (amazon)

-1x screwdriver (to adjust sensor) (amazon)

Add Pico to Breadboard

IMG_6566.jpeg
Screenshot 2024-01-01 114409.png

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

IMG_6572.jpeg

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

IMG_6581.jpeg

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

Screenshot 2023-12-31 224825.png

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

IMG_6574.jpeg
IMG_6575.jpeg
Trouble shooting sound sensor-- calibration

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!