/ Capacitive_Touch_Sensors_on_the_Raspberry_Pi / MC-Melons.py
MC-Melons.py
1 # SPDX-FileCopyrightText: 2019 Mikey Sklar for Adafruit Industries 2 # 3 # SPDX-License-Identifier: MIT 4 5 import time 6 import board 7 import mcpi.minecraft as minecraft 8 from digitalio import DigitalInOut, Direction 9 10 mc = minecraft.Minecraft.create() 11 12 pad_pin = board.D23 13 14 pad = DigitalInOut(pad_pin) 15 pad.direction = Direction.INPUT 16 17 # melon block 18 block_type = 103 19 20 while True: 21 22 if pad.value: 23 pos = mc.player.getPos() 24 x = pos.x 25 y = pos.y 26 z = pos.z 27 mc.setBlock(x, y, z, block_type) 28 29 time.sleep(0.1)