def amap(x, in_min, in_max, out_min, out_max):
    """
    This is an analog of Arduino's `map()` function. It maps the `x` located in range `[in_min, in_max]` to a new value located in range `[out_min, out_max]` accordingly to the position of `x` in `in`-range

    This function does not check if `x` is really located in `in`-range. In some situations it may be needed to perform `constrain(x, in_min, in_max)` before passing to this function as `x`

    Parameters
    ----------
    `x` : The value to be mapped

    `in_min` : The lower limit of input range (inclusive)

    `in_max` : The upper limit of input range (inclusive)

    `out_min` : The lower limit of output range (inclusive)

    `out_max` : The upper limit of output range (inclusive)

    Returns
    -------
    `x` which is mapped to the `out`-range

    Examples
    --------
    >>> amap(5, 0, 10, 10, 20)
    15.0
    >>> amap(0, -10, 10, 0, 10)
    5.0
    >>> amap(-8, -8, -4, 2, 6)
    2.0
    >>> amap(2.5, 0, 5, 0, 1)
    0.5
    """

    return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min