Skip to content

Commit

Permalink
Bash Script - GPIO Configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
gkca committed Feb 28, 2019
1 parent 69d2be9 commit 849949a
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Raspberry Pi/gpio_config.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 849949a

Please sign in to comment.