From 849949a88718dab582fff49a72a2497c93696795 Mon Sep 17 00:00:00 2001 From: gkca Date: Fri, 1 Mar 2019 00:22:18 +0300 Subject: [PATCH] Bash Script - GPIO Configuration --- Raspberry Pi/gpio_config.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 Raspberry Pi/gpio_config.sh diff --git a/Raspberry Pi/gpio_config.sh b/Raspberry Pi/gpio_config.sh new file mode 100755 index 0000000..3dbb3dc --- /dev/null +++ b/Raspberry Pi/gpio_config.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +# Define some variables + +ERROR_MESSAGE="use [script_name] [Arg1: PIN number] [Arg2: in or out]" + +case $# in + + 1) + echo $1 > /sys/class/gpio/unexport + echo "GPIO pin unexported" + ;; + + 2) + echo $1 > /sys/class/gpio/export + sleep 1 + echo $2 > /sys/class/gpio/gpio$1/direction + echo "GPIO pin is set" + ;; + + *) + echo $ERROR_MESSAGE + ;; +esac