Skip to content

Instantly share code, notes, and snippets.

@rxseger
Last active October 6, 2016 02:58
Show Gist options
  • Save rxseger/7ea4c3c5d3d4811e69ad7cf3b524bb6d to your computer and use it in GitHub Desktop.
Save rxseger/7ea4c3c5d3d4811e69ad7cf3b524bb6d to your computer and use it in GitHub Desktop.
toggle ac power outlet GPIO
#!/usr/bin/python
import sys
import RPi.GPIO as GPIO
if len(sys.argv) < 2:
print 'usage: %s [0/1]' % (sys.argv[0],)
raise SystemExit
GPIO.setmode(GPIO.BOARD)
CONTROL = 16 # G23
GPIO.setwarnings(False)
GPIO.setup(CONTROL, GPIO.OUT, initial=GPIO.LOW)
on = bool(int(sys.argv[1]))
print on
GPIO.output(CONTROL, on)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment