Festive lights programming challenge


#1

Program your own coloured lights display in uLisp with my Festive Lights Programming Challenge:

For details see: Festive Lights Programming Challenge.

If you devise a good display, post your uLisp program in this thread.


Thoughts inspired by the new Arduino Uno Mini
#2

I have an old version of uLisp where I added support for WS2812Bs (Neopixels). If someone wants to use those I could add support for them to the current version, too.


#3

Fairy lights

Here’s one of my festive lights displays. This one simulates flashing incandescent coloured fairy lights. Each LED flashes with a regular period, and with a consistent colour, but the periods of all the lights are slightly different, so the sequence of flashes is continuously varying and unpredictable.

The colours are all chosen from an orange/red/pink range of hues, defined by the variable col:

(defvar col '((0 0 31) (31 0 31) (0 0 255) (31 0 255)
              (255 0 255) (0 31 255) (31 31 255) (255 31 255)))

Here’s the flashing lights display program, dis:

(defun dis ()
  (let ((bri 7) (off 11))
    (with-spi (str 10)
      (loop
       (dotimes (n 32767)
         (dotimes (i 4) (write-byte #x00 str))
         (dotimes (i 30)
           (let* ((j (mod (+ 7 (* i 13)) 30))
                  (k (mod n (+ off j))))
             (write-byte (+ (min bri 7) #xE0) str)
             (mapc (lambda (x) (write-byte (if (zerop k) x 0) str))
                   (nth (logand j 7) col))))
         (dotimes (i 4) (write-byte #x00 str)))))))

It will just fit on an Arduino Uno.

The variable off determines the average rate of flashing. Increase it to, say, 31 for slower flashes.

The variable bri determines the brightness. Reduce it for dimmer lights.