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

# VELLEMAN VMA313
# The device includes an on-chip Hall voltage generator for magnetic sensing, an amplifier that amplifies the Hall voltage,
# a Schmitt trigger to provide switching hysteresis for noise rejection and an open-collector output.

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

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

while True: # Infinite loop
    if hall.value() == 0: # Reads the hall's value
        print("Magnet close") # If the magnet is close
    else:
        print("Magnet far") # If the magnet is far
    time.sleep(0.25) # Delay