This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#送り先の電話番号、国番号+81のあと、先頭の0を外して記載します。 | |
TELNO="+81806857xxxx" | |
#SMS送信関数 | |
sms() { | |
killall cat | |
cat /dev/ttyACM0 & | |
echo -en "AT+CMGF=1\r" > /dev/ttyACM0 | |
echo -en "AT+CMGS=\"$TELNO\"\r" > /dev/ttyACM0 | |
echo -en "$1\x1a" > /dev/ttyACM0 | |
} | |
#GPIOの設定 | |
echo 19 > /sys/class/gpio/export | |
echo in > /sys/class/gpio/gpio19/direciton | |
echo 20 > /sys/class/gpio/export | |
echo in > /sys/class/gpio/gpio20/direction | |
while true | |
do | |
#GPIOの値を読み込み、押されていたらボタン名をSMSで送信する | |
BTNA=`cat /sys/class/gpio/gpio19/value`; | |
if [ "$BTNA" = "0" ]; then | |
echo "ButtonA pressed"; | |
sms "ButtonA"; | |
fi | |
BTNB=`cat /sys/class/gpio/gpio20/value`; | |
if [ "$BTNB" = "0" ]; then | |
echo "ButtonB pressed"; | |
sms "ButtonB"; | |
sleep 1 | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment