###########################
### Code in MicroPython ###
###########################

# VELLEMAN VMA327
# End-Stop Switch

from machine import Pin # For hardware functions
import time # For time functions

switch = Pin(27, Pin.IN, Pin.PULL_UP) # Set pin 27 as an input with internal pull-up resistor

while True: # Infinite loop
    if switch.value() == 0: # Reads the switch's value
        print("Switch pressed") # If the switch is pressed
    else:
        print("Switch released") # If the switch is released
    time.sleep(0.25) # Delay