Stormer97

simple mcpi-gpio program

Apr 24th, 2013
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. import time
  2. import RPi.GPIO as GPIO # import the GPIO module
  3. import minecraft
  4. import block
  5. import time
  6.  
  7. mc = minecraft.Minecraft.create()
  8. GPIO.setmode(GPIO.BCM) # sets the mode to BCM (meaning that pin 17 refers to the 17th pin AKA GPIO 11
  9. GPIO.setup(17, GPIO.OUT) # marks pin 17 as an output pin
  10. GPIO.output(17, True) # sets pin 17 to true. Since pin 17 (GPIO 11) is marked as output, this will turn on your LED
  11.  
  12. while True:
  13.         time.sleep(0.1)
  14.         playerPos = mc.player.getPos()
  15.         y = int(playerPos.y)
  16.         if y > 20:
  17.                 GPIO.output(17, True)
  18.         else:
  19.                 GPIO.output(17, False)
Advertisement
Add Comment
Please, Sign In to add comment