Projects/Netlight: Difference between revisions
< Projects
No edit summary |
(→Script) |
||
Line 11: | Line 11: | ||
== Script == | == Script == | ||
#!/bin/sh | #!/bin/sh | ||
IP="8.8.8.8" | IP="8.8.8.8" | ||
TIMEOUT="2" | TIMEOUT="2" | ||
GPIO_GREEN="23" | GPIO_GREEN="23" | ||
GPIO_RED="24" | GPIO_RED="24" | ||
# no user-servicable parts below | # no user-servicable parts below | ||
echo ${GPIO_GREEN} > /sys/class/gpio/export | echo ${GPIO_GREEN} > /sys/class/gpio/export | ||
echo "out" > /sys/class/gpio/gpio${GPIO_GREEN}/direction | echo "out" > /sys/class/gpio/gpio${GPIO_GREEN}/direction | ||
echo ${GPIO_RED} > /sys/class/gpio/export | echo ${GPIO_RED} > /sys/class/gpio/export | ||
echo "out" > /sys/class/gpio/gpio${GPIO_RED}/direction | echo "out" > /sys/class/gpio/gpio${GPIO_RED}/direction | ||
while [ 1 ]; do | while [ 1 ]; do | ||
ping -c 1 -W 2 -qq ${IP} > /dev/null 2>&1 | |||
ec=$? | |||
if [ ${ec} -eq 0 ]; then | |||
echo "1" > /sys/class/gpio/gpio${GPIO_GREEN}/value | |||
sleep 3 | |||
echo "0" > /sys/class/gpio/gpio${GPIO_RED}/value | |||
else | |||
echo "0" > /sys/class/gpio/gpio${GPIO_GREEN}/value | |||
echo "1" > /sys/class/gpio/gpio${GPIO_RED}/value | |||
fi | |||
done | done | ||
== Gallery == | == Gallery == |
Revision as of 13:53, 27 July 2012
Project Netlight | |
---|---|
Name | Netlight |
Start | |
End | |
Contact | Piet |
Website | |
Information | The network traffic light at haxogreen |
Status | Production |
http://www.youtube.com/watch?v=uxdJv-h0Fks
Script
#!/bin/sh IP="8.8.8.8" TIMEOUT="2" GPIO_GREEN="23" GPIO_RED="24" # no user-servicable parts below echo ${GPIO_GREEN} > /sys/class/gpio/export echo "out" > /sys/class/gpio/gpio${GPIO_GREEN}/direction echo ${GPIO_RED} > /sys/class/gpio/export echo "out" > /sys/class/gpio/gpio${GPIO_RED}/direction while [ 1 ]; do ping -c 1 -W 2 -qq ${IP} > /dev/null 2>&1 ec=$? if [ ${ec} -eq 0 ]; then echo "1" > /sys/class/gpio/gpio${GPIO_GREEN}/value sleep 3 echo "0" > /sys/class/gpio/gpio${GPIO_RED}/value else echo "0" > /sys/class/gpio/gpio${GPIO_GREEN}/value echo "1" > /sys/class/gpio/gpio${GPIO_RED}/value fi done
Gallery
-
-
Raspberry PI with a relay board connected to it