Handling of formula

Hello PyrusBoy

Although you don't say so, I assume the problem is that the value displayed on the LCD is not the answer you expect, given the input voltages?

Couple of ideas, and a request.

You could add print statements to your calculation code to print the intermediate results to serial monitor. For example:

  val1 = analogRead(val1);              //Vin  reads analog input A2 into val
Serial.print("val1 = ");
Serial.println(val1);
  val2 = analogRead(val2);              //V50  reads analog input A3 into val
Serial.print("val2 = ");
Serial.println(val2);
etc

If any of the variables have been declared as type float or double, use the following to print them to 4 decimal places:

Serial.println(val11, 4);

You would need to include the following in the setup() function:

Serial.begin(9600); // make sure you have the same speed set in serial monitor

Second, what units do the three input voltages need to be in for your equations to work properly? Volts?

  val1 = analogRead(val1);              //Vin  reads analog input A2 into val
  val2 = analogRead(val2);              //V50  reads analog input A3 into val
  val3 = analogRead(val3);              //VL   reads analog input A4 into Val

The value returned by analogRead() will be an integer between 0 and 1023, where 0 equates to 0V input and 1023 equates to 5V input (unless you have reconfigured the voltage reference).

If you are expecting volts, you will need to do some arithmetic on val1 etc before you use them further.

The request is, please post your complete program. Use code tags (the "#" button above the row of smileys). Often, problems originate in other places in the program, for example where you declare these variables.

Regards

Ray