from machine import Pin
from utime import sleep
# Define the pins where the buttons are connected
button_pins = [Pin(2, Pin.IN, Pin.PULL_UP),
Pin(3, Pin.IN, Pin.PULL_UP),
Pin(4, Pin.IN, Pin.PULL_UP),
Pin(5, Pin.IN, Pin.PULL_UP),
Pin(6, Pin.IN, Pin.PULL_UP),
Pin(7, Pin.IN, Pin.PULL_UP)]
def read_buttons():
# Create the binary array based on button states
return [0 if button.value() == 1 else 1 for button in button_pins]
while True:
# Read button states and create the binary array
binary_array = read_buttons()
# Print the binary array (representing button states)
print(binary_array)
# Wait for a short time before reading again
time.sleep(0.1)