Last active
August 29, 2015 14:04
-
-
Save bennuttall/2fac0b87ac3524025d29 to your computer and use it in GitHub Desktop.
rpio gpio example
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
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) |
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
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") |
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
while True: | |
x, y, z = mc.player.getTilePos() | |
mc.setBlock(x, y, z, flower) | |
sleep(0.1) |
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
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() |
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
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() |
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
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