Created
May 9, 2017 11:45
-
-
Save yakutozcan/f8fa5268fa3eb12d7205b8742ea8c397 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import os | |
import time | |
import RPi.GPIO as GPIO | |
GPIO.setmode(GPIO.BCM) | |
GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP) | |
OldPinStatus = None | |
while True: | |
PinStatus = GPIO.input(18) | |
if OldPinStatus != PinStatus: | |
if PinStatus: | |
os.system("sudo service ssh start") | |
else: | |
os.system("sudo service ssh stop") | |
OldPinStatus = PinStatus | |
time.sleep(0.1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment