using void and returning the values

Hello everyone. I was wondering if there is a way to return a value with void as i am using multiple sensors.

i was wondering if it is possible to call a void and returning the values to the parameters,
as you see i am calling the void with sensor1 in the parameters, but i can not change the value of it. is there a way to return the value the a parameter of the function?

void auto_calibrate(int sensor_value,int sensor_max_value, int flow_frequency)
{ int sensor_change = 0;
  if (sensor_value >= sensor_max_value) 
    {
    sensor_max_value = sensor_value;
    sensor_change = sensor_value-sensor_max_value;
    Serial.print("sensor_max_value: ");
    Serial.println(sensor_max_value);
    //Serial.print("new value: ");
    //Serial.println(sensor_value);
    //Serial.println(" L/hour");
    return sensor_max_value;

    }
    
  flow_frequency = 0;
} 

auto_calibrate(sensor1,sensor1_max,sensor_1_flow_frequency);
auto_calibrate(sensor2,sensor2_max,sensor_2_flow_frequency);

i was wondering if it is possible to call a void

You do not call a void, you call a function. The word void before its name indicates specifically that it will not return a value. In general only one variable can be returned from a function, although there are ways to return multiple values.

Some reading on functions would seem to be in order.

What you have is a FUNCTION, not a void. Having void in front of the function name is telling the system that you do NOT want to return anything. If you want to return e.g. an int change the void to int. See Arduino - FunctionDeclaration

Steve

you can pass a reference to your variable, thus making it mutable within the function.

The function looks like this:

void auto_calibrate(int& sensor_value, int& sensor_max_value, int& flow_frequency) // the & indicates that you are passing a reference to the original value, not a copy
{
  ...
}

and call it the same way...

auto_calibrate(sensor1,sensor1_max,sensor_1_flow_frequency);
auto_calibrate(sensor2,sensor2_max,sensor_2_flow_frequency);