Skip to content

Instantly share code, notes, and snippets.

@vdavez
Created May 24, 2015 20:10
Show Gist options
  • Save vdavez/d39042fa598a0d0901f3 to your computer and use it in GitHub Desktop.
Save vdavez/d39042fa598a0d0901f3 to your computer and use it in GitHub Desktop.
Raspberry Pi scripts
#!/usr/bin/env python3
from time import sleep
import requests
try:
import RPi.GPIO as GPIO
except RuntimeError:
print("Error importing RPi.GPIO! This is probably because you need superuser privileges. You can achieve this by using 'sudo' to run your script")
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
led = 12
GPIO.setup(led, GPIO.OUT)
r = requests.head("https://esq.io")
if r.status_code == 200:
GPIO.output(led, 1)
sleep(10)
GPIO.cleanup()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment