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.

  1. A 10ms trigger, which turns the lights on for 10ms, and more importantly: it turns them off again! This overrides whatever state the lights were on before. So if the lights were already on, the lights actually turn off! This trigger also sends a reset message for the trigger that turns the lights on for 850ms.
  2. After a brief delay of 10ms (10ms+10ms=20ms in total for the delay node) the actual trigger to turn on the lights for 850ms is sent and the lights are turned on again, until the time is up or another messages arrives.

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.

Flow for the #Christmas Module

A video of the lights in action can be found here: https://instagram.com/p/B6JEaKuFxgI/