Skip to content

Instantly share code, notes, and snippets.

@worldwise001
Created July 2, 2019 05:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save worldwise001/0983772ef6ea2eee7419db8462e342f9 to your computer and use it in GitHub Desktop.
Save worldwise001/0983772ef6ea2eee7419db8462e342f9 to your computer and use it in GitHub Desktop.
simple bash script to turn printer on
#!/bin/bash
PIN="26"
if [ ! -d "/sys/class/gpio/gpio$PIN" ]; then
echo $PIN > /sys/class/gpio/export;
fi
if [ "`cat /sys/class/gpio/gpio$PIN/direction`" != "out" ]; then
echo out > /sys/class/gpio/gpio$PIN/direction;
fi
case $1 in
on)
echo "Turning printer on";
echo 1 > /sys/class/gpio/gpio$PIN/value;
;;
off)
echo "Turning printer off";
echo 0 > /sys/class/gpio/gpio$PIN/value;
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment