0
import neopixel
import board
import sounddevice as sd
from numpy import linalg as LA
import numpy as np

def getvolume(indata, outdata, frames, time, status):
       volume_norm = np.linalg.norm(indata)*10

with sd.Stream(callback=getvolume):
       sd.sleep(250)

pixels = neopixel.NeoPixel(board.D18, 144)
pixels.fill((volume_norm, volume_norm, volume_norm))`

I want the code to make the LED strip shine brighter the louder the sound is. It currently doesn't do anything. What am I doing wrong?

  • You could try moving the `pixels.fill()` call into the callback function. – Matthias Feb 28 '19 at 09:45
  • you should do two things to troubleshoot: 1) add `print((volume_norm, volume_norm, volume_norm))` to make sure that there is an acceptable volume. 2) start with a primer to make sure your lights are working and wired correctly: `pixels.fill((200,200,200))` – billmanH Oct 04 '19 at 00:15

0 Answers0