'*********************************************************************
'*          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
'-----------------------------------------------------------------------