Skip to content

Commit 4615bf3

Browse files
author
Mikey Sklar
committed
ported to python3, tested with minecraft, circuitpython ready
1 parent 58906a7 commit 4615bf3

2 files changed

Lines changed: 9 additions & 10 deletions

File tree

Binary file not shown.
Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
1-
import RPi.GPIO as GPIO
21
import time
2+
import board
33
import mcpi.minecraft as minecraft
4-
mc = minecraft.Minecraft.create()
5-
6-
GPIO.setmode(GPIO.BCM)
4+
from digitalio import DigitalInOut, Direction
75

8-
padPin = 23
6+
mc = minecraft.Minecraft.create()
97

10-
GPIO.setup(padPin, GPIO.IN)
8+
pad_pin = board.D23
9+
pad = DigitalInOut(pad_pin)
10+
pad.direction = Direction.INPUT
1111

12-
alreadyPressed = False
12+
already_pressed = False
1313

1414
while True:
15-
padPressed = GPIO.input(padPin)
1615

17-
if padPressed and not alreadyPressed:
16+
if pad.value and not already_pressed:
1817
pos = mc.player.getPos()
1918
x = pos.x
2019
y = pos.y + 10
2120
z = pos.z
2221
mc.player.setPos(x, y, z)
23-
alreadyPressed = padPressed
22+
alreadyPressed = pad.value
2423
time.sleep(0.1)

0 commit comments

Comments
 (0)