Using blink(1) as a programmable nightlight

Tod E. Kurt edited this page Aug 12, 2014 · 9 revisions

You can easily make blink(1) into a nightlight by plugging it into a standard USB charger or other source of 5VDC that isn't connected to a computer. blink(1) will detect it's not talking over USB and will instead play the light sequence programmed into it.

blink(1) as a nightlight

The default light sequence in blink(1) is white -> red -> green -> blue -> ... and you can change that.

There are 12 slots in the light sequencer, numbered 0 to 11. (In blink1mk2, there are more) Each slot has an RGB color and a duration in milliseconds. blink(1) plays all 12 slots in order, and then loops forever.

Currently to do that you need to use the blink1-tool command-line program with the "setpattline", "getpattline", "savepattern" and "play" commands. You can get blink1-tool in the "releases" page of this github (scroll down to find the latest release of it for your OS).

To set the color sequence to flash purple,white,purple,white, then wait 5 seconds and repeat, type the following into a Terminal window (once you've downloaded blink1-tool for your OS):

./blink1-tool -m 1000 --rgb 0xff,0x00,0xff --setpattline 0
./blink1-tool -m 1000 --rgb 0xff,0xff,0xff --setpattline 1 
./blink1-tool -m 1000 --rgb 0xff,0x00,0xff --setpattline 2
./blink1-tool -m 1000 --rgb 0xff,0xff,0xff --setpattline 3
./blink1-tool -m 1000 --rgb 0x00,0x00,0x00 --setpattline 4
./blink1-tool -m 5000 --rgb 0x00,0x00,0x00 --setpattline 5
./blink1-tool -m    0 --rgb 0x00,0x00,0x00 --setpattline 6
./blink1-tool -m    0 --rgb 0x00,0x00,0x00 --setpattline 7
./blink1-tool -m    0 --rgb 0x00,0x00,0x00 --setpattline 8
./blink1-tool -m    0 --rgb 0x00,0x00,0x00 --setpattline 9
./blink1-tool -m    0 --rgb 0x00,0x00,0x00 --setpattline 10
./blink1-tool -m    0 --rgb 0x00,0x00,0x00 --setpattline 11
./blink1-tool --savepattern

You can test out your pattern at any time by doing

./blink1-tool --play 1   # plays pattern
./blink1-tool --play 0   # stops pattern

Turning off the pattern

If you want to not have any pattern play, set all the pattern lines to off, like:

./blink1-tool -m 1000 --rgb 0x00,0x00,0x00 --setpattline 0
./blink1-tool -m 1000 --rgb 0x00,0x00,0x00 --setpattline 1
./blink1-tool -m 1000 --rgb 0x00,0x00,0x00 --setpattline 2
./blink1-tool -m 1000 --rgb 0x00,0x00,0x00 --setpattline 3
./blink1-tool -m 1000 --rgb 0x00,0x00,0x00 --setpattline 4
./blink1-tool -m 1000 --rgb 0x00,0x00,0x00 --setpattline 5
./blink1-tool -m 1000 --rgb 0x00,0x00,0x00 --setpattline 6
./blink1-tool -m 1000 --rgb 0x00,0x00,0x00 --setpattline 7
./blink1-tool -m 1000 --rgb 0x00,0x00,0x00 --setpattline 8
./blink1-tool -m 1000 --rgb 0x00,0x00,0x00 --setpattline 9
./blink1-tool -m 1000 --rgb 0x00,0x00,0x00 --setpattline 10
./blink1-tool -m 1000 --rgb 0x00,0x00,0x00 --setpattline 11
./blink1-tool --savepattern