import array import time import audiobusio import board import neopixel import librms mic = audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA, bit_depth=16) cadena = neopixel.NeoPixel(board.D8, 10) valores = array.array('H', [0] * 100) while True: mic.record(valores, len(valores)) magnitud = librms.rms(valores) if magnitud > 12000: cadena.fill((255, 0, 0)) else: if magnitud > 10000: cadena.fill((255, 127, 0)) else: if magnitud > 8000: cadena.fill((255, 255, 0)) else: if magnitud > 6000: cadena.fill((0, 255, 0)) else: cadena.fill((0, 0, 0)) time.sleep(0.2)