「PIAST スクリプト」の版間の差分
提供: VoIP-Info.jp
(→LED制御) |
|||
96行目: | 96行目: | ||
if [ "$PINNO" = "" ] | if [ "$PINNO" = "" ] | ||
then | then | ||
− | echo "Usage: | + | echo "Usage: ledoff.sh [LED](1-4)" |
exit | exit | ||
fi | fi |
2016年3月5日 (土) 00:35時点における版
PIASTの各種周辺機器を使用するためのスクリプト類
注意:GPIOの番号は"物理"です。wiringpiを使う場合の番号ではありません。
GPIO初期化
- GPIO設定(gpioinit.sh)
#!/bin/sh PINNS="4 6 13 19 26" GPIOPATH="/sys/class/gpio" for i in $PINNS do GPORT=gpio$i if [ ! -d $GPIOPATH/$GPORT ] then echo $i > $GPIOPATH/export echo "out" > $GPIOPATH/$GPORT/direction fi done
- GPIO解放(gpiounconfig.sh)
#!/bin/sh PINNS="4 6 13 19 26" GPIOPATH="/sys/class/gpio" for i in $PINNS do GPORT=gpio$i if [ -d $GPIOPATH/$GPORT ] then echo $i > $GPIOPATH/unexport fi done
リレー制御用
- リレーオン(relayon.sh)
#!/bin/sh PINNO=4 RELAYPORT=gpio$PINNO GPIOPATH="/sys/class/gpio" if [ ! -d $GPIOPATH/$RELAYPORT ] then echo $PINNO > $GPIOPATH/export echo "out" > $GPIOPATH/$RELAYPORT/direction fi echo "1" > $GPIOPATH/$RELAYPORT/value
- リレーオフ(relayoff.sh)
#!/bin/sh PINNO=4 RELAYPORT=gpio$PINNO GPIOPATH="/sys/class/gpio" if [ ! -d $GPIOPATH/$RELAYPORT ] then echo $PINNO > $GPIOPATH/export echo "out" > $GPIOPATH/$RELAYPORT/direction fi echo "0" > $GPIOPATH/$RELAYPORT/valu
LED制御
- LED点灯(ledon.sh)
#!/bin/sh PINNOS="6 13 19 26" GPIOPATH="/sys/class/gpio" PINNO=`echo $PINNOS | cut -f$1 -d' '` if [ "$PINNO" = "" ] then echo "Usage: ledon.sh [LED](1-4)" exit fi LEDPORT=gpio$PINNO if [ ! -d $GPIOPATH/$LEDPORT ] then echo $PINNO > $GPIOPATH/export echo "out" > $GPIOPATH/$LEDPORT/direction fi echo "1" > $GPIOPATH/$LEDPORT/value
- LED消灯(ledoff.sh)
#!/bin/sh PINNOS="6 13 19 26" GPIOPATH="/sys/class/gpio" PINNO=`echo $PINNOS | cut -f$1 -d' '` if [ "$PINNO" = "" ] then echo "Usage: ledoff.sh [LED](1-4)" exit fi LEDPORT=gpio$PINNO if [ ! -d $GPIOPATH/$LEDPORT ] then echo $PINNO > $GPIOPATH/export echo "out" > $GPIOPATH/$LEDPORT/direction fi echo "0" > $GPIOPATH/$LEDPORT/value