Roger Ngo's Website

Personal thoughts about life and tech written down.

Christmas Lights With The Raspberry Pi 2 - 2016 Edition!

Christmas 2016 - Mad Max from Roger Ngo on Vimeo.

Well, here it is!!! This is my 2016 Christmas Lighting project. Same as last year, I used a Raspberry Pi and SSR to drive 7 channels of lights and 1 channel off a main. I definitely chose the wrong song this year with Mad Max. It was super difficult to sync up with. I initially wanted to write a high-pass filter to grab all the beats but it turned out really bad so I decided to just procedurally write all the Python code again. Enjoy the 6 minutes of choreography!

Special thanks to my girlfriend for putting up with the huge fire hazard in our living room, me making a mess and not cleaning up after myself right away and finally helping me with stringing the lights (looks better than 2015, right?)

Here are some technical details:

  1. 2500 lines of Python
  2. 2 Threads, 1 for the background music, the other for driving 8 lights. (PyGame is useful for this. :))
  3. Some parts of the choreography, I am pushing a thread sleep for 0.05 seconds. Sounds like nothing, but it really is hard when you are trying to sync up with 7 other lights and making sure all the timing and delays are correct.
  4. I used cereo as an HTTP server to basically flip the switch to start playing the song. :) Also, the tree lighting is controllable through REST calls. WHY did I write an HTTP server from scratch just to do this when I could have done out of the box? I don't know... I really don't... Hehe...
  5. Wrote this all through vi.. and I still don't know vi. Hah. (Just kidding. i, ESC, :w, :q, amirite?)
  6. Don't try writing a high pass filter if you obviously know from the start it's not going to work. A waste of time. But I would welcome anyone to try -- and also if you do and are successful, please remember me, and give me some of your profit. :)