「PIAST スクリプト」の版間の差分

提供: VoIP-Info.jp
移動先: 案内検索
 
(同じ利用者による、間の1版が非表示)
1行目: 1行目:
 +
[[カテゴリ:PIAST]]
 +
 
PIASTの各種周辺機器を使用するためのスクリプト類<br>
 
PIASTの各種周辺機器を使用するためのスクリプト類<br>
 
注意:GPIOの番号は"物理"です。wiringpiを使う場合の番号ではありません。<br>
 
注意:GPIOの番号は"物理"です。wiringpiを使う場合の番号ではありません。<br>
96行目: 98行目:
 
  if [ "$PINNO" = "" ]
 
  if [ "$PINNO" = "" ]
 
  then
 
  then
     echo "Usage: ledon.sh [LED](1-4)"
+
     echo "Usage: ledoff.sh [LED](1-4)"
 
     exit
 
     exit
 
  fi
 
  fi

2016年3月10日 (木) 00:11時点における最新版


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