Skip to content

Instantly share code, notes, and snippets.

@yakutozcan
Created May 9, 2017 11:45
Show Gist options
  • Save yakutozcan/f8fa5268fa3eb12d7205b8742ea8c397 to your computer and use it in GitHub Desktop.
Save yakutozcan/f8fa5268fa3eb12d7205b8742ea8c397 to your computer and use it in GitHub Desktop.
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