def fan_speed_for_temp(temp):
    """Determine fan PWM duty cycle for given temp."""
    if temp < 26:
        return 0
    elif temp < 28:
        return 40
    elif temp < 32:
        return 50
    elif temp < 35:
        return 80
    else:
        return 100