Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • hofalab/sound-2-light-workshop
  • steph/sound-2-light-workshop
  • weja/sound-2-light-workshop
3 results
Show changes
Commits on Source (22)
Bilder/Lichter.gif

58.2 KiB

Bilder/Lichter.png

226 KiB

Bilder/galerie.jpeg

155 KiB

Bilder/standort.png

809 KiB

File added
This diff is collapsed.
# Sound 2 Light Workshop # Sound 2 Light Workshop
![](/Bilder/Lichter.gif){height=250px}
Tauche ein in die faszinierende Welt der Technik und baue deinen eigenen „Sound Visualisierer“! In diesem Workshop erfährst du, wie du Umgebungsgeräusche in Echtzeit über farbige LEDs sichtbar machst. Tauche ein in die faszinierende Welt der Technik und baue deinen eigenen „Sound Visualisierer“! In diesem Workshop erfährst du, wie du Umgebungsgeräusche in Echtzeit über farbige LEDs sichtbar machst.
Was du lernst: ## Was du lernst:
Grundlegende Einblicke in den 3D-Druck<br /> Grundlegende Einblicke in den 3D-Druck<br />
Die Kunst des Lötens/n<br /> Die Kunst des Lötens<br />
Einführung in die Microcontroller Programmierung<br /> Einführung in die Microcontroller Programmierung<br />
<br /> <br />
Workshopdauer ca. 4 Stunden<br /> Workshopdauer ca. 4 Stunden<br />
Aler: ab 12 Jahren<br /> Alter: ab 12 Jahren<br />
<br /> <br />
Organisatoren: Stephan und Werner<br /> Organisatoren: Stephan und Werner<br />
<br /> <br />
Mit dem Bausatz kannst du auch eigene Projekte umsetzen, da der Microcontroller über eine USB-Schnittstelle programmierbar ist. Beispielsweise könntest du ein Thermometer oder ein Spiel entwickeln. Makerspaces wie das HoFaLab können dir dabei helfen. Mit dem Bausatz kannst du auch eigene Projekte umsetzen, da der Microcontroller über eine USB-Schnittstelle programmierbar ist. Beispielsweise könntest du ein Thermometer oder ein Spiel entwickeln. Makerspaces wie das HoFaLab können dir dabei helfen.
Das fertige Produkt darfst du mit nach Hause nehmen. Das fertige Produkt darfst du mit nach Hause nehmen.<br />
Ablauf:
13:00 Uhr: Begrüßung und Übersicht
13:15 Uhr: Einstieg in Blockscad
13:45 Uhr: Individuelle Anpassung des Modells
14:15 Uhr: Pause
14:30 Uhr: Elektronik löten
15:30 Uhr: Schaltung zusammenbauen
16:00 Uhr: Inbetriebnahme der Sound 2 Light Software und Ausprobieren
16:30 Uhr: Blick in den Code und Fragen und Antworten
Kontakt:
Werner: Werner@hofalab.de
Stephan: stephan.kiener@itech-bs14.de
Wir würden uns über eine Benachrichtigung freuen, wenn ihr teilnehmen wollt.
Auf jeden Fall pünktlich erscheinen!
Über eine Spende für die Materialien wären wir begeistert.
File added
# Using PIO to drive a set of WS2812 LEDs.
import array, utime, _thread
from machine import Pin
import rp2
@rp2.asm_pio(sideset_init=rp2.PIO.OUT_LOW, out_shiftdir=rp2.PIO.SHIFT_LEFT, autopull=True, pull_thresh=24)
def ws2812():
T1 = 2
T2 = 5
T3 = 3
wrap_target()
label("bitloop")
out(x, 1) .side(0) [T3 - 1]
jmp(not_x, "do_zero") .side(1) [T1 - 1]
jmp("bitloop") .side(1) [T2 - 1]
label("do_zero")
nop() .side(0) [T2 - 1]
wrap()
class strip:
''' Methods to manipulate 2812 stripes:
pset ( position, color,[optional show(0 or 1)])
fill ( (r,g,b),[optional show(0 or 1)] )
rotate ( steps,[optional show(0 or 1)] )
shift ( steps,[optional show(0 or 1)] )
rainbow ( [starthue , [endhue]],[optional show(0 or 1)] )
show ()
Properties:
BRIGHTNESS (value between 0 and 1)
'''
counter = 0
thread_user = None
def __init__(self,NUM_LEDS, PIN_NUM, BRIGHTNESS):
self.NUM_LEDS = NUM_LEDS
self.PIN_NUM = PIN_NUM
self.BRIGHTNESS = BRIGHTNESS
self.now = 0
if strip.counter < 4:
# Create the StateMachine
self.sm = rp2.StateMachine(strip.counter, ws2812, freq=8_000_000, sideset_base=Pin(self.PIN_NUM))
self.counter=strip.counter
# Start the StateMachine
self.sm.active(1)
# Displayarray on the LEDs
self.ar = array.array("I", [0 for _ in range(self.NUM_LEDS)])
print("Strip with state machine",strip.counter,"on pin",self.PIN_NUM,"active")
else:
print("the maximum of 4 state machines was reached ")
strip.counter += 1
def renew(self,attr,obj):
print("renew state machine",self.counter)
del self
def _dimm(self,col):
c1 = int(((col >> 16) & 0xFF) * self.BRIGHTNESS)
c2 = int(((col >> 8) & 0xFF) * self.BRIGHTNESS)
c3 = int((col & 0xFF) * self.BRIGHTNESS)
return (c1<<16) + (c2<<8) + c3
def show(self):
if strip.thread_user == None:
_thread.start_new_thread(self._put_thread,())
elif (strip.thread_user == self):
#Waiting for tread completion
while strip.thread_user != None:
pass
_thread.start_new_thread(self._put_thread,())
else:
self.sm.put(self.ar, 8)
utime.sleep_us(50)
def _put_thread(self):
strip.thread_user = self
ar_out=self.ar[:]
self.sm.put(ar_out, 8)
utime.sleep_us(50)
strip.thread_user = None
def pset(self,i, col,show=False):
self.ar[i] = self._dimm((col[1]<<16) + (col[0]<<8) + col[2])
if show==1:
self.show()
def fill(self,col,show=False):
fillcol=self._dimm((col[1]<<16) + (col[0]<<8) + col[2])
self.ar = array.array("I", [fillcol for _ in range(self.NUM_LEDS)])
if show:
self.show()
def rotate(self,step,show=False):
cp = array.array("I", self.ar[-step:])
cp.extend(self.ar[:-step])
self.ar = cp
if show:
self.show()
def shift(self,step,show=False):
if step >= 0:
cp = array.array("I",[0 for _ in range(step)])
cp.extend(self.ar[:-step])
else:
cp = array.array("I",self.ar[-step:])
blackpix = array.array("I",[0]*-step)
cp.extend(blackpix[:])
self.ar = cp
if show:
self.show()
def rainbow(self, start=0, end=360,show=False):
steps=int((end-start)/self.NUM_LEDS)
for i in range(self.NUM_LEDS):
self.pset(i, hue2col(start+(i*steps)))
if show:
self.show()
##########################################################################
# color definations
def hue2col(angle):
rgb = [0,0,0]
sec = ((0,1),(1,2),(2,0))
rgb[sec[int(angle/120)][1]]=int(255/120*(angle%120))
rgb[sec[int(angle/120)][0]]=int(255/120*(120-(angle%120)))
return (rgb[0],rgb[1],rgb[2])
RED = (hue2col(0))
YEL = (hue2col(60))
GRE = (hue2col(120))
CYA = (hue2col(180))
BLU = (hue2col(240))
PUR = (hue2col(300))
WHT = (255, 255, 255)
BLK = (0,0,0)
COLORS = (RED, YEL, GRE, CYA, BLU, PUR, WHT, BLK)
'''
Function test for WS2812 strips
Version: 0.1 from 26.05.2024
License: CC-BY Weja/HoFaLab
'''
number_pixels = 10
brightness = 0.4 # value between 0 and 1
import WS2812onRP2040
import time
pixels = WS2812onRP2040.strip(number_pixels,29,0.3)
pixels.pset(0,(255,0,0))
while True:
pixels.rotate(1)
pixels.show()
time.sleep(0.3)
\ No newline at end of file
'''
Example program for use in the soldering workshop.
Should work on a WS2812 strip of any length.
The variable "softgain" controls the sensitivity in selfcalibrating mode and
the length of the strip is entered in "number_pixels".
Works with a MAX4466 microphone amplifier module.
Version: 0.2 from 26.05.2024
License: CC-BY Weja/HoFaLab
'''
number_pixels = 10
brightness = 0.4 # value between 0 and 1
import WS2812onRP2040
import time
from machine import ADC, Pin, Timer
softgain,mode,average = 0,0,0 #init values
mic = ADC(Pin(28)) # create ADC object on ADC pin
pixels = WS2812onRP2040.strip(number_pixels,29,0.3)
timer1 = Timer(period=10000, mode=Timer.PERIODIC, callback=lambda t:changemode())
def changemode(): #0-left,1-right,2-center lights
global mode
mode = (mode+1)%3
def vu_meter():
vu=0
for r in range(500):
vu+=abs(mic.read_u16() - 32767)
return (vu/500)/32767
while True:
sound = vu_meter()
average = average/50*49 + sound/50
softgain = 4/average # selfcalibrating
if sound < 0.02: #mute
softgain=1
hue = min(int(sound*softgain*50),359)
#print(sound,softgain,hue) #debug info
col = WS2812onRP2040.hue2col(hue)
anz = min(int(sound*softgain),number_pixels)
pixels.fill((0,0,0))
for p in range(anz):
if mode == 0: #left to right
pixels.pset(number_pixels-1-p,(col))
if mode == 1: #right to left
pixels.pset(p,(col))
if mode == 2: # left/right to center
pixels.pset(p,(col))
pixels.pset(number_pixels-1-p,(col))
pixels.show()
time.sleep(0.125) # refresh time for the lights.
\ No newline at end of file
'''
Example program for use in the soldering workshop.
Should work on a WS2812 strip of any length.
The variable "softgain" controls the sensitivity in selfcalibrating mode and
the length of the strip is entered in "number_pixels".
Works with a MAX4466 microphone amplifier module.
Version: 0.2 from 26.05.2024
License: CC-BY Weja/HoFaLab
'''
number_pixels = 10
brightness = 0.4 # value between 0 and 1
import WS2812onRP2040
import time
from machine import ADC, Pin, Timer
softgain,mode,average = 0,0,0 #init values
mic = ADC(Pin(28)) # create ADC object on ADC pin
pixels = WS2812onRP2040.strip(number_pixels,29,brightness)
timer1 = Timer(period=10000, mode=Timer.PERIODIC, callback=lambda t:changemode())
def changemode(): #0-left,1-right,2-center lights
global mode
mode = (mode+1)%3
def vu_meter():
vu=0
for r in range(500):
vu+=abs(mic.read_u16() - 32767)
return (vu/500)/32767
time.sleep(5) # wait 5 sec. before start
while True:
sound = vu_meter()
average = average/50*49 + sound/50
softgain = 4/average # selfcalibrating
if sound < 0.03: #mute - depending on the microphone and ambient noise
softgain=1
hue = min(int(sound*softgain*50),359)
#print(sound,softgain,hue) #debug info
col = WS2812onRP2040.hue2col(hue)
anz = min(int(sound*softgain),number_pixels)
pixels.fill((0,0,0))
for p in range(anz):
if mode == 0: #left to right
pixels.pset(number_pixels-1-p,(col))
if mode == 1: #right to left
pixels.pset(p,(col))
if mode == 2: # left/right to center
pixels.pset(p,(col))
pixels.pset(number_pixels-1-p,(col))
pixels.show()
time.sleep(0.125) # refresh time for the lights.
\ No newline at end of file