Skip to content

Electric Liver Bird

Julian Todd edited this page Feb 14, 2020 · 3 revisions

photo_2020-02-14_16-58-40

The Liver Bird on the wall in the main room is subscribed to a few MQTT topics, which set various parts of it to different colours. (Inside it there's a Raspberry Pi and an Arduino - the Pi deals with the MQTT interface and sends commands over serial to the Arduino, which talks to the RGB LEDs)

Topic Payload Description
liverbird/paper colour set the newspaper to the colour given in colour
liverbird/percent percentage,from colour,to colour,top from colour,top to colour fill percentage of the Liver Bird fading from from colour to to colour and filling in the upper section with a fade from top from colour to top to colour
liverbird/head colour set the head to the colour given in colour
liverbird/beak colour set the beak to the colour given in colour
liverbird/eye colour set the eye to the colour given in colour
liverbird/row n,colour set row n to the colour given in colour. There are 20 rows
liverbird/column n,colour set body column n to the colour given in colour. There are 10 columns
liverbird/led n,colour set individual LED n to the colour given in colour
liverbird/party n/a PARTY! (flash the lights lots). To stop the party send a liverbird/fadeout message
liverbird/fadeout n/a Fade body and leg LEDs to black
liverbird/body 1st col colour,2nd col colour,...,10th col colour set the colour of all the body columns at once
liverbird/defaults n/a reset the legs and beak (at present) to their default colours

Colours can be definied in a number of ways:

  • Decimal (normal) numbers will be converted to hexadecimal and used as #RRGGBB
  • #hex numbers will be treated like CSS colours, two digits each of red, green, blue"));
  • %h|s|v is treated as three numbers for a colour in the HSV colourspace. H is the hue (0-255!), S is the saturation (0-255), and L is the value (0-255)

Example Python code

Coding of the Liverbird could be done from within the Node-RED framework. But this example is a Python script for educational purposes. You can build a forwarding flow from an external mqtt-broker to the mqtt.local broker so it can be controlled externally.

# pip install paho-mqtt
import paho.mqtt.client as mqtt
client = mqtt.Client("", True, None, mqtt.MQTTv31)
client.connect("mqtt.local", 1883)
client.is_connected()

import time
def mpub(topic, payload, delay=0.02):
    client.publish(topic, payload)
    time.sleep(delay)
    
col = "#c02050"
mpub("liverbird/beak", "#802020")
mpub("liverbird/paper", "#FF0000")
mpub("liverbird/head", "#000070")
mpub("liverbird/row", "0,%s"%("#a0a0a0"), 0.4)
for i in range(20):
    if i < 19:
        mpub("liverbird/row", "%d,%s"%(i+1, "#a0a0a0"))
    col = "#002050" if (i%2) else "#10e010"
    mpub("liverbird/row", "%d,%s"%(i, col))
mpub("liverbird/paper", "#FFFFFF")
col = "%50|250|250"
mpub("liverbird/eye", "#0000FF")
mpub("liverbird/head", "#FF0000")
mpub("liverbird/beak", "%50|250|250")

Competition

There is a proposal to hold a Liverbird dressing competition with two categories: static and 5 second animation.

Clone this wiki locally
You can’t perform that action at this time.