File tree Expand file tree Collapse file tree
Capacitive_Touch_Sensors_on_the_Raspberry_Pi Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import RPi .GPIO as GPIO
21import time
2+ import board
33import 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
1414while 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 )
You can’t perform that action at this time.
0 commit comments