Skip to content

Instantly share code, notes, and snippets.

@ericoporto
Created November 1, 2015 17:23
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 ericoporto/44833e55d7c2af88e3bd to your computer and use it in GitHub Desktop.
Save ericoporto/44833e55d7c2af88e3bd to your computer and use it in GitHub Desktop.
Turn a pin from Raspberry on at a time for a duration period.
#!/bin/bash
# call using ./pinsched <time> <duration> <pin number>
# example: ./pinsched 14:00 2hours 5
timeat="$1"
duration="$2"
ledpim="$3"
endtime=`date +%H:%M -d " $timeat today + $duration"`
gpio -g mode $ledpin out
echo "gpio -g write $ledpin 1" | at $timeat
echo "gpio -g write $ledpin 0" | at $endtime
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment