MY PROJECT OF THE YEAR 2024

Place your projects here
Post Reply
User avatar
PeterN
Posts: 642
Joined: Mon Feb 08, 2021 7:56 pm
Location: Krefeld, Germany
Has thanked: 297 times
Been thanked: 360 times
Contact:

MY PROJECT OF THE YEAR 2024

Post by PeterN »

I have found that the small projects often turn out to be more important than the big ones.

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.

angels.JPEG

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
You do not have the required permissions to view the files attached to this post.
User avatar
cicciocb
Site Admin
Posts: 2784
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 592 times
Been thanked: 1990 times
Contact:

Re: MY PROJECT OF THE YEAR 2024

Post by cicciocb »

Thanks Peter, I'm happy to see that Annex contributes with your decorations.

For me, Annex is present in all my home's decorative lighting, including a "NeoPixel based WS2812b Dot Matrix Display" and a "HUB75 Matrix Displays - DMAMATRIX".
This year, I also experimented with implementing a mini MQTT network using an ESP32 module as an MQTT broker.
I incorporated a series of "Smart Socket Power Monitoring" and "Wifi Smart Switch" devices (flashed with Tasmota and OpenBeken) to control the various Christmas lights.

Using the IoTMQTTPand app on my phone, it is really very easy to control all these modules.
BeanieBots
Posts: 522
Joined: Tue Jun 21, 2022 2:17 pm
Location: South coast UK
Has thanked: 292 times
Been thanked: 163 times

Re: MY PROJECT OF THE YEAR 2024

Post by BeanieBots »

My modest contribution for Xmas.
Everyone has there own taste about Xmas decs. Personally, I'm not a fan of flashing/twinkling lights.
I also can never make my mind what colour light should go where, so I knocked up this little bit of code.
Every 5 seconds it picks an LED and a colour at random. It then slowly fades the chosen LED from the original colour to the new colour.
The colours have been deffined to suit my LEDs and eyes. Also, the values are set low to reduce current below 1A when using lots of LEDs.

Code: [Local Link Removed for Guests]

'*********************************************************************
'*          WS2812B Subtle LED controller                            *
'*   Beaniebots  V1.0.0      Dec 24                                  *
'*                                                                   *
'*********************************************************************

LED_count = 25    'The number of LEDs in the string
Colour_Count = 8 'The total number of colours to be used
LED_Pin = 13
Brightness = 0.6

Dim Colour(8)

Colour(0) = neo.rgb(1,1,1)      'dim white
Colour(1) = neo.rgb(128,0,0)    'red
Colour(2) = neo.rgb(0,80,0)     'green
Colour(3) = neo.rgb(0,0,255)    'blue
Colour(4) = neo.rgb(96,0,64)    'magenta pink
Colour(5) = neo.rgb(0,64,32)    'cyan  turquise
Colour(6) = neo.rgb(96,70,0)    'yellow
Colour(7) = neo.rgb(100,25,0)   'orange
Colour(8) = neo.rgb(70,70,96)   'White

Start_col = 0
New_col = neo.rgb(5,5,5)
LED_Num=0

neo.setup LED_Pin, LED_count
neo.clear 0'undocumented
NEO.STRIP 0, LED_count, COLOUR(0)' [, disable]

For N = 0 to 8
  LED_num = N
  New_col = Colour(N)
  NEO.PIXEL N, NEO.DIM (Colour(N), Brightness) ,0
  pause 2.50
Next N
pause 5000
'-----------------------------------------------------------------------
do
  Gosub Pick_LED
  Gosub Pick_col
  Gosub Transition
  Pause 5000 
loop
'-----------------------------------------------------------------------
wait

Pick_LED:
  LED_Old = LED_Num
  Do
  LED_Num = rnd(LED_count)
  Loop until LED_Num <> LED_Old
Return
'-----------------------------------------------------------------------
Pick_col:
  Colour_num = rnd(Colour_Count)
  New_col = Colour(Colour_num+1)
  New_col = NEO.DIM (New_col, Brightness)
Return
'-----------------------------------------------------------------------
Transition:
Start_col = NEO.GETPIXEL (LED_num)
For progress = 0 to 1 step 0.05
  Trans_col = neo.linearblend(start_col, New_col, progress) 
  NEO.PIXEL LED_Num, Trans_col ,0
  pause 150
Next progress
neo.refresh
'pause 10
return
'-----------------------------------------------------------------------
Last edited by BeanieBots on Wed Dec 18, 2024 10:47 am, edited 1 time in total.
User avatar
PeterN
Posts: 642
Joined: Mon Feb 08, 2021 7:56 pm
Location: Krefeld, Germany
Has thanked: 297 times
Been thanked: 360 times
Contact:

Re: MY PROJECT OF THE YEAR 2024

Post by PeterN »

Thank you, Beaniebots!
I especially like that you made the transitions so smooth.
I will also integrate this into a ceiling light
BeanieBots
Posts: 522
Joined: Tue Jun 21, 2022 2:17 pm
Location: South coast UK
Has thanked: 292 times
Been thanked: 163 times

Re: MY PROJECT OF THE YEAR 2024

Post by BeanieBots »

Thanks for your interest Peter. It was mainly about getting subtle changes.
I'm colour blind, so it also had to go through several iterations with my Wife which went a little like this.
What do think of this dear. "Too flicky".
What about this. "The orange looks green".
What about this. "when are you going to paint the kitchen?"
What about this. "Ooh, I like that" ....

Quickly save, post and look for a paint brush.
It's far from finished, need to add a web page to set speeds, colours and time of day scheduling for brightness, but it got me a few 'brownie points' to help with not getting on with the kitchen renovation ;)
Post Reply