Skip to content
Snippets Groups Projects
Commit 62f2cc2e authored by Werner Jarmatz's avatar Werner Jarmatz
Browse files

Upload New File

parent b7cd7cda
No related branches found
No related tags found
No related merge requests found
'''
Example program for use in a workshop.
Should work on a WS2812 strip with a lenght of 10 pixels.
The length of the strip is entered in "number_pixels".
Works with a MAX4466 microphone amplifier module.
Version: 0.1 from 02.08.2024
License: CC-BY Weja/HoFaLab
'''
number_pixels = 10
brightness = 0.4 # value between 0 and 1
Sensitivity = 1.0 #
import WS2812onRP2040
import time
from machine import ADC, Pin, Timer
import math
import sys
try:
micvcc = Pin(11, Pin.OUT)
micgnd = Pin(10, Pin.OUT)
micgnd.value(0)
micvcc.value(1)
mic = ADC(Pin(26)) # create ADC object on ADC pin
pixels = WS2812onRP2040.strip(number_pixels,29,0.3)
time.sleep(5) # wait 5 sec. before start
def vu_meter():
vu=0
for r in range(50):
vu+=abs(mic.read_u16() - 32767)
return (vu/100000) * Sensitivity
def peak():
peak = 0
for r in range(2000):
peak = max(peak, vu_meter())
return peak*peak
for t in range(200):
pixels.fill((0,0,0))
val = peak()
anz = min(val+0.5,10)
col = WS2812onRP2040.hue2col(120-(anz*12))
#print(val)
for p in range(anz):
pixels.pset(p,col)
pixels.show()
#time.sleep(0.1)
except:
pixels.fill((0,0,0),1)
time.sleep(0.1)
sys.exit()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment