Last active
September 9, 2016 08:27
-
-
Save jezman/c6f2186b38c648df8e66d2c6926dbc09 to your computer and use it in GitHub Desktop.
RaspberryPi relay switch. 0 - NC, 1 - NO
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import RPi.GPIO as GPIO | |
import sys | |
PIN = 4 | |
GPIO.setwarnings(False) | |
GPIO.setmode(GPIO.BCM) | |
GPIO.setup(PIN, GPIO.OUT) | |
def relay_off(): | |
GPIO.output(PIN, False) | |
def relay_on(): | |
GPIO.output(PIN, True) | |
def unknown(): | |
print 'Unknow' | |
switch = {'0': relay_off, '1': relay_on} | |
switch.get(sys.argv[1], unknown)() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment