Exemple #1
0
  mc.setBlocks(LIFT_X-2, LIFT_Y, LIFT_Z-2, LIFT_X+2, 
    LIFT_Y+(NUM_FLOORS*FLOOR_HEIGHT), LIFT_Z+2, block.AIR.id)


# Game loop

try: # if this code fails, it jumps to "finally"
  # Use Broadcom pin numbering scheme for GPIOs
  GPIO.setmode(GPIO.BCM)
  
  # Set all button GPIOs to be inputs so you can read their state
  for p in FLOOR_GPIO:
    GPIO.setup(p, GPIO.IN)
    
  # Setup the display ready for use
  display.setup(GPIO, DISPLAY_GPIO, ON)

  # Create the lift shaft, diamond request blocks, and footplate
  createLift()
  drawLift(lift_y, block.STONE.id)

  # Loop forever (or until CTRL-C)
  while True:
    # Delay a short time (to prevent computer being too busy!)
    time.sleep(0.5)
    
    # Check if there are any pending requests to process
    checkRequests()
    
    # Move the lift in automatic mode
    autoLift() # change to manualLift() if you want "service mode"
import mcpi.minecraft as minecraft
import mcpi.block as block
import mcpi.minecraftstuff as minecraftstuff
import time
import random
import thread
import anyio.seg7 as display
import anyio.GPIO as GPIO

BUTTON = 4
LED_PINS = [7,6,14,16,10,8,9,15]

GPIO.setmode(GPIO.BCM)
GPIO.setup(BUTTON, GPIO.IN)
ON = False # common-anode, set to True for common cathode
display.setup(GPIO, LED_PINS, ON)

#arena constants
ARENAX = 20
ARENAZ = 30
ARENAY = 5
RIVERWIDTH = 6

def createArena(pos):
    mc = minecraft.Minecraft.create()
    pos.x
    mc.setBlocks(pos.x - 1, pos.y, pos.z - 1,
                 pos.x + ARENAX + 1, pos.y - 3,
                 pos.z + ARENAZ + 1, block.GRASS.id)
    mc.setBlocks(pos.x - 1, pos.y + 1, pos.z - 1,
                 pos.x + ARENAX + 1, pos.y + ARENAY, pos.z + ARENAZ + 1,
Exemple #3
0
# testSeg7.py - Test a 7-segment display

import anyio.seg7 as display
import time

# Use this for Raspberry Pi
#import RPi.GPIO as GPIO
#LED_PINS = [10,22,25,8,7,9,11,15]

# Use this for Arduino
import anyio.GPIO as GPIO

LED_PINS = [7, 6, 14, 16, 10, 8, 9, 15]

GPIO.setmode(GPIO.BCM)

ON = False  # common-anode. Set to True for a common cathode display

display.setup(GPIO, LED_PINS, ON)

try:
    while True:
        for d in range(10):
            display.write(str(d))
            time.sleep(0.5)
finally:
    GPIO.cleanup()

# END