Free delivery on orders above Rs 900 | For Enquiry Call/Whatsapp +91 7276757409

How You Can Create Your Own Sound Reactive WS2812B Led Strip Using Raspberry Pi Pico

Creating a sound-reactive WS2812B LED strip using a Raspberry Pi Pico can be a fun project! Here’s a basic guide to get you started:

Get the Required Hardware:

Wire up the WS2812B LED Strip:

    • Connect the data pin of the WS2812B LED strip to a GPIO pin on the Raspberry Pi Pico.
    • Connect the ground and power pins of the LED strip to the corresponding pins on the Pico.
    • Connect the microphone or audio source to the Pico.

Install Thonny (Python IDE) and Adafruit CircuitPython:

Install Required Libraries:

    • Open Thonny and install the required CircuitPython libraries. You’ll need the adafruit_pixelbuf, adafruit_pypixelbuf, and adafruit_ws2812

Write the Python Script:

    • Write a Python script to read the audio input, analyze the sound, and control the WS2812B LEDs
Code-

import array
import math
import audiobusio
import board
import neopixel

# Configuration:
LED_COUNT = 30 # Adjust based on the number of LEDs in your strip
MIC_PIN = board.A0 # Adjust based on the GPIO pin connected to the microphone
BRIGHTNESS = 0.2 # Adjust the LED brightness

pixels = neopixel.NeoPixel(board.GP0, LED_COUNT, auto_write=False)
mic = audiobusio.PDMIn(MIC_PIN, sample_rate=16000, bit_depth=16)

def normalize(values, target_rms):
current_rms = math.sqrt(sum(i ** 2 for i in values) / len(values))
scale = target_rms / current_rms
return array.array(“H”, int(i * scale) for i in values)

while True:
samples = array.array(“H”, mic.record(samples))
normalized_samples = normalize(samples, 32767)

for i in range(LED_COUNT):
intensity = normalized_samples[i] / 65535.0
pixels[i] = (int(intensity * 255), 0, 0)

pixels.show()

Upload and Run the Script:

    • Save the Python script to your Raspberry Pi Pico.
    • Run the script, and the LED strip should react to the sound picked up by the microphone.

Remember, this is a basic example, and you can customize the script based on your preferences. Adjustments can be made to the LED arrangement, color patterns, and sensitivity to create a more dynamic sound-reactive LED display. Have fun experimenting!

 

2
299.10
GET DISCOUNT CODE

It will take just few seconds to claim 7% Discount, After Submitting check Email for Coupon code.

    X
    GET DISCOUNT CODE