Difference between revisions of "Bash the Lights"
Line 1: | Line 1: | ||
{{Project | {{Project | ||
+ | |picture=Powerbutton.jpg | ||
|ProjectSkills=Basic electronics, Programming, Bash, Powerbar | |ProjectSkills=Basic electronics, Programming, Bash, Powerbar | ||
|ProjectStatus=Active | |ProjectStatus=Active | ||
Line 32: | Line 33: | ||
[[File:Powerbutton_location.jpg|thumb|The PowerButton]] | [[File:Powerbutton_location.jpg|thumb|The PowerButton]] | ||
It runs from the /etc/rc.local | It runs from the /etc/rc.local | ||
+ | |||
+ | Currently it only polls once every second so please be patient . . | ||
+ | |||
+ | As you cold see from the code the safest way to boot the thing is with the button in the OFF state and after it is booted switch the lights ON |
Revision as of 03:41, 22 November 2014
Projects | |
---|---|
Participants | Brainsmoke, Realitygaps, The JinX, Wizzup |
Skills | Basic electronics, Programming, Bash, Powerbar |
Status | Active |
Niche | Electronics |
Purpose | World domination |
A simple light switch that can turn on and off the Powerbar lights.
It's a simple GL-Inet device running some curl and bash magic
#!/bin/ash echo 20 > /sys/class/gpio/export echo in > /sys/class/gpio/gpio20/direction state=`cat /sys/class/gpio/gpio20/value` while true do if [[ `cat /sys/class/gpio/gpio20/value` -eq 0 && $state -ne 0 ]] then curl -d state=Off http://powerbar.ti:5000/preset/alloff state=0 fi if [[ `cat /sys/class/gpio/gpio20/value` -eq 1 && $state -ne 1 ]] then curl -d state=Off http://powerbar.ti:5000/preset/lightson state=1 fi sleep 1 done
It runs from the /etc/rc.local
Currently it only polls once every second so please be patient . .
As you cold see from the code the safest way to boot the thing is with the button in the OFF state and after it is booted switch the lights ON