My wife is a collector of old angel figurines, which are traditionally part of our Christmas decorations every year. The collection includes an organ found at a flea market—unfortunately with a defective mechanical music box.
Thanks to [Local Link Removed for Guests] , Annex 1.70, and an M5Stack Atom Echo, the organ is now reequipped with a link to heavenly music.
In addition, the sky in this scene is enhanced from above by a strip of NeoPixels. The color and brightness of these NeoPixels change to the rhythm of the music.
The quick and dirty modified script:
Code: [Local Link Removed for Guests]
data "Coral_of_the_bells_1", "http://neufeld.bplaced.net/mp3/CotB_1.mp3"
data "Coral_of_the_bells_2", "http://neufeld.bplaced.net/mp3/Carol_of_the_bells.mp3"
data "Beatles Radio", "http://www.beatlesradio.com:8000/stream/1/"
data "DLF-Radio", "http://st01.sslstream.dlf.de/dlf/01/128/mp3/stream.mp3"
data "DLF-Kultur", "http://st02.sslstream.dlf.de/dlf/02/128/mp3/stream.mp3"
data "DLF-Nova", "http://st03.sslstream.dlf.de/dlf/03/128/mp3/stream.mp3"
data "1Live", "http://wdr-1live-live.icecast.wdr.de/wdr/1live/live/mp3/128/stream.mp3"
data "WDR2", "http://wdr-wdr2-rheinruhr.icecast.wdr.de/wdr/wdr2/rheinruhr/mp3/128/stream.mp3"
data "WDR3", "http://wdr-wdr3-live.icecast.wdr.de/wdr/wdr3/live/mp3/128/stream.mp3"
data "WDR4", "http://wdr-wdr4-live.icecast.wdr.de/wdr/wdr4/live/mp3/128/stream.mp3"
data "WDR5", "http://wdr-wdr5-live.icecast.wdr.de/wdr/wdr5/live/mp3/128/stream.mp3"
data "S T O P", "http://XXXX"
data "end"
LED_NUM = 48 'Number of LEDs in the strip
LED_PIN = 26
vol = 20 ' default volume
myradio = 0 ' default radio station
IPADR$ =word$(IP$,1)
But = 39
pin.mode But, input ' it is active low
But_p = 1
cnt = 0
vol_dir = 1 ' 1= vol up, -1 = vol down
' defines after how many time the button is
' recognised as volume change
CNT_TRESHOLD = 15
'onerror goto reset
'neo.setup 27, 1 ' set the neo rgb led on the pin 27 (internal NeoPixel of ATOM echo)
neo.setup LED_PIN,LED_NUM ' set the neo rgb led on the pin 27 (Groove_port)
neo.pixel 0, 0,0,0
play.setup 1,12,1 'use external DAC, encreased buffer, mono
gosub change_volume
dim radio$(100,2) ' max 100 radios
read r$
p = 0
while r$ <> "end"
radio$(p, 0) = r$
read radio$(p, 1)
read r$
p = p + 1
wend
nb_radios = p
wlog "nb radios "; nb_radios
gosub web_page
onHtmlReload web_page
onHtmlChange change_volume
'timer0 50, update_led
timer0 100, update_led
gosub change_radio
wait
end
'##################################################################
'##################################################################
web_page:
cls
cssexternal "/w3.css"
cssexternal "/html_obj.css"
r$ = ""
a$ = ""
a$ = a$ + "<h1 style='text-align:center'>O R G E L</h1>"
a$ = a$ + "<h3 style='text-align:center'>---------------------------------</h1>"
a$ = a$ + |<table class="w3-auto w3-center">|
for z = 0 to nb_radios - 1
do_button z, radio$(z, 0), r$
if (z mod 3) = 0 then a$ = a$ + "<tr>"
a$ = a$ + "<td>" + r$
'if (z mod 4) = 3 then a$ = a$ + "</tr>"
next z
a$ = a$ + "</table>"
' add the slider
a$ = a$ + |<div class="w3-center">Volume<br>|
a$ = a$ + |<input data-var="vol" class="slider w3-blue" value="|+ str$(vol) + |" oninput="cmdChange(event)" type="range" min="0" max="100">|
a$ = a$ + |</div>|
a$ = a$ + |<center><br><br><a href="http://api.qrserver.com/v1/create-qr-code/?size=100x100&data=http://| + IPADR$
a$ = a$ + |" target="_blank">QR-Code-Adresse dieser Seite </a></center>|
html a$
return
'##################################################################
change_radio:
' myRadio is a variable returned from the html;
' it is defined in the html code
wlog myRadio,radio$(myradio,1)
play.stream radio$(myRadio, 1), 30000
return
'##################################################################
change_volume:
play.volume vol
wlog "Volume",vol
return
' simple create a button with the given index and text
sub do_button idx, text$, ret$
if (idx mod 2) = 0 then
ret$ = |<button class='w3-button w3-green w3-small w3-round-xxlarge' style='border:2px solid #999'|
else
ret$ = |<button class='w3-button w3-red w3-small w3-round-xxlarge' style='border:2px solid #999'|
end if
ret$ = ret$ + | onclick="connection.send('cmd:gotoMyRadio=| + str$(idx) + | : gosub change_radio')">|
ret$ = ret$ + text$ + |</button>|
end sub
'##################################################################
update_led:
r= log(1+play.VU_L+Play.VU_R)*2.5
if r>(LED_NUM/2-2) then r=LED_NUM/2-1
count=(count +1) mod 10
if count =1 then
RR=rnd(60)
GG=rnd(30)
BB=rnd(10)
endif
neo.strip 0,LED_NUM, 0,0,0,1
if play.isplaying then
'neo.strip (LED_NUM/2-1 )-(r),(LED_NUM/2)+(r), rnd(70),rnd(70),rnd(40),0
'neo.strip (LED_NUM/2-1 )-(r),(LED_NUM/2)+(r), rnd(50),rnd(30),rnd(10),0
neo.strip (LED_NUM/2-1 )-(r),(LED_NUM/2)+(r),RR,GG,BB,0
else
X=(val(right$(time$,2))) mod LED_NUM
neo.pixel X,RND(30),RND(30),0
endif
if pin(But) = 0 then cnt = cnt + 1
if (cnt > CNT_TRESHOLD) and (pin(But) = 0) then
vol = vol + vol_dir
if vol < 0 then vol = 0
if vol > 100 then vol = 100
play.volume vol
wlog "vol change "; vol
end if
if (pin(But) = 1) and (But_p = 0) then ' release button
if (cnt > CNT_TRESHOLD) then
vol_dir = - vol_dir ' change the direction of the volume control
else
' change radio
myRadio = myRadio + 1
if (myRadio >= nb_radios) then myRadio = 0
gosub change_radio
end if
cnt = 0
end if
But_p = pin(But)
return
'##################################################################
reset:
reboot
return
Many thanks to Francesco/CiccioCB for his fantastic work that makes it possible to bring such little projects to life without a large effort.
***
*** Maybe you want to show your tiny project of the year here with a photo too,
*** just to give a little feedback at the end of this Annex-supported year?
***
Happy DIY and good luck,
Peter