差分

移動先: 案内検索

PIAST スクリプト

1,930 バイト追加, 2016年2月29日 (月) 00:14
ページの作成:「(今のところ)俺メモ ===GPIO初期化=== *GPIO設定(gpioinit.sh) #!/bin/sh PINNS="4 6 13 19 26" GPIOPATH="/sys/class/gpio" for i in $PINNS do GPORT...」
(今のところ)俺メモ
===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: 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 "0" > $GPIOPATH/$LEDPORT/value

案内メニュー

VoIp-Info.jp

HP Directplus -HP公式オンラインストア-