def map_val(val, in_min, in_max, out_min, out_max):
    """
    Function based on the map function for the arduino
    https://www.arduino.cc/reference/en/language/functions/math/map/
    """
    return (val - in_min) * (out_max - out_min) / (in_max - in_min) + out_min