Last Christmas we updated our #Love module with twinkling lights and sleigh bells!
For this module the twitter nodes listens to all incoming mentions with the #Christmas. Each menti0n triggers a short sleigh-bell sample. To make it sound less monotone, it cycles through a selection of nine different sleigh bell sounds.
Since the sleigh bell sounds are more or less equal in length, the goal was to have the lights light up for roughly the same duration of each sleigh-bell sound. This was handled by having a GPIO output of the rasperry by switching to a high output for 850ms. Conveniently the Rasperry Pi’s GPIO emits 3.3V when switched on, and the LEDs chain with the Christmas trees requires the same voltage.
If we left the flow like this, the lights would have just stayed on permanently due to the constant barrage of Christmas mentions. But we wanted twinkling lights! To get the lights to twinkle, a short “interruptor” or 10ms Trigger was added. So whenever a mention is registered, two signals are sent to the LED sub-flow.
Some experimentation was needed to get the right amounts of delay and trigger durations for the interruptions. A 10ms duration of “off time” seems to be just long enough to achieve a twinkling impression, without it seeming like the lights are faulty. Shorter durations are almost not noticeable.
A video of the lights in action can be found here: https://instagram.com/p/B6JEaKuFxgI/