Overview
In this guide, we will make a Voice Activated Light using a Sound Sensor & Raspberry Pi Pico Board.
The sound sensor detects the level change of the sound sensor through Raspberry Pi Pico. When the sound loudness is greater than the threshold, the sensor is triggered, and then the RGB LED is controlled to light up. Then the LED will automatically turn off after waiting for 3 seconds.
Components Required
In this guide, I used Elecrow Raspberry Pi Pico Starter Kit to test different Modules. You can buy the kit and perform some other operations as well. From this kit, you can use the following components.
1. Raspberry Pi Pico Board -1
2. Sound Sensor – 1
3. RGB LED Module – 1
4. Breadboard -1
5. Jumper Wires – 10
6. Micro-USB Cable
Sound Sensor
The sound sensor acts like a microphone, which is used to receive sound waves. The sensor has a built-in condenser electret microphone that is sensitive to sound. Sound waves make the electret film in the microphone vibrate, resulting in a change in capacitance and a small voltage corresponding to the change. This voltage is then converted into a 0-5V voltage, which is received by the data collector after A/D
conversion and transmitted to the microcontroller.
The Sound sensor module has 4 pins VCC, GND, Digital Out, and Analog Out. We can either use the AO pin as an output for analog reading or the DO pin as an output for digital readout. In this module, we only have D0 Pin which is the digital output pin.
Circuit Diagram & Hardware Setup
The circuit for Voice Activated Light using Sound Sensor & Raspberry Pi Pico Board is given below.
Connect the Sound Sensor VCC, GND & Out pin to Raspberry Pi Pico 5V (VBUS), GND & GP0 Pin.
Similarly connect the R, G & B Pin of the RGB LED to Raspberry Pi Pico GP2, GP3 & GP4 Pin respectively. Connect the GND Pin of RGB LED to Pico GND Pin.
MicroPython Code/Program
Copy the following code and paste it into the Thonny Editor.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
from machine import Pin,PWM from utime import sleep_ms sound = Pin(0, Pin.IN, Pin.PULL_DOWN) # Port internal pull-down Led_R = PWM(Pin(2)) Led_G = PWM(Pin(3)) Led_B = PWM(Pin(4)) Led_R.freq(2000) Led_G.freq(2000) Led_B.freq(2000) if __name__ == '__main__': while True: print(sound.value()) if sound.value() == 1: Led_R.duty_u16(65535) Led_G.duty_u16(65535) Led_B.duty_u16(65535) sleep_ms(2000) else: Led_R.duty_u16(0) Led_G.duty_u16(0) Led_B.duty_u16(0) |
Run the script and start testing the above-connected circuit.
When you clap near the sensor the LED will turn ON for 2 seconds. Then it will turn OFF. You can retest this multiple times.










