Skip to content

Instantly share code, notes, and snippets.

@bennuttall
Last active August 29, 2015 14:04
Show Gist options
  • Save bennuttall/2fac0b87ac3524025d29 to your computer and use it in GitHub Desktop.
Save bennuttall/2fac0b87ac3524025d29 to your computer and use it in GitHub Desktop.
rpio gpio example
from energenie import switch_on, switch_off
from time import sleep
# turn a plug socket on and off by number
switch_on(1)
switch_off(1)
# turn a plug socket on, then turn off after 10 seconds
switch_on(4)
sleep(10)
switch_off(4)
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.IN, GPIO.PUD_UP)
if GPIO.input(17):
print("Active")
else:
print("Not active")
while True:
x, y, z = mc.player.getTilePos()
mc.setBlock(x, y, z, flower)
sleep(0.1)
import picamera
from time import sleep
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.IN, GPIO.PUD_UP)
with picamera.PiCamera() as camera:
camera.start_preview()
GPIO.wait_for_edge(17, GPIO.FALLING)
sleep(5)
camera.capture('/home/pi/image.jpg')
camera.stop_preview()
import picamera
from time import sleep
with picamera.PiCamera() as camera:
camera.start_preview()
sleep(5)
camera.capture('/home/pi/image.jpg')
camera.stop_preview()
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.IN, GPIO.PUD_UP)
GPIO.wait_for_edge(17, GPIO.FALLING)
print("Don't touch me!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment