We put up some holiday lights in the Mission Street windows. (We call them Holiday Lights both as a gesture of ecumenical goodwill and to annoy the "War on Christmas" wingnuts.)
Naturally, you can control them on the web using the bare-bones interface at URL: http://lights.noisebridge.net/
This is served by a pure Python webserver running on a Fit-PC Ubuntu micro-PC. Lights are switched with a 8-channel serial-controlled relay board. Each of the four windows has two strings of LEDs, white and colored. Facing Mission St, the white LEDs on the leftmost window are on channel 0, the colored ones on channel 1. The next window over has white on channel 2 and so forth.
You can find the code in github
This is the script that runs forever, and does the Actual Work of switching the lights on and off. It reads the file /home/lights/sequence, which defines the light sequence, and then uses the RelayControl class to communicate with the external relay bank.
The text file read by filelooop.py that defines the light sequence currently active. The first line of this file defines how long (in milliseconds) we wait before advancing to the next state. The rest of the file is a list of states to iterate through. For example:
1000 10000000 01000000 00100000 00010000 00001000 00000100 00000010 00000001
We sleep for 1 second (1000 milliseconds) between states. Each line of 8 digits controls the relays, one char per channel. In the first state, the first light is on, and the rest are off. In the second state, the second light is on, and the rest are off. In the third state, the third light is on, and the rest are off. etc.
A list of pre-programed sequences.
A full webserver/framework implementation, currently configured to listen on port 8080. When you request "/", it returns a list of hyperlinks to each of the *.seq files in lights's home directory. If you click on one of those links, it copies the contents from the *.seq file to /home/lights/sequence, so filelooop.py will start processing it instead of whatever it was previously processing.
When you use webserver.py to request a *.seq file, it "<h1>Thanks!</h1>". We should make it look pretty, and probably also have a meta refresh to redirect the user back to / (the directory listing) after a few seconds, or something.
There's a really fun "direct line" into the control of the lights:
Hint: hex works