Problem with Uno Rev3 float logic, help!

I only began using arduino roughly 3 days ago and I wanted to use my first arduino to control my solar battery bank relay connected to a heater to discharge it (risky business, i know but I hear they are very reliable so I decided to trust it.) and when the battery dies enough it cuts the relay to allow the batteries to rest until they’re charged again.

Anyways I am simply stuck with trying to be able to compare float values; for instance 12.50 > 12.40 is not breaking my “while” thread and it is getting very frusterating.
I tried multiple methods of breaking the loop and they all either constantly break the loop or never break the loop when the voltage values reach the lower threshold.

Here is my script for anyone who is interested in taking a look to help out a noob!

/*

By: Joshua

battery discharge monitor.

*/

const float UpperVThreshhold = 13.10; //setyour max voltage you want your system to reach before the relay activates

const float LowerVThreshhold = 12.70; //setyour minimum voltage you want your system to reach before the relay deactivate

int Relay = 2; //Set pin3 as the relay pin

// the setup routine runs once when you press reset:

void setup() {

// initialize serial communication at 9600 bits per second:

Serial.begin(9600);

pinMode(Relay,OUTPUT);

digitalWrite(Relay, LOW);
}

// the loop routine runs over and over again forever:

void loop() {

// read the input on analog pin 0:

float sensorValue = analogRead(A1);

// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):

Serial.print("Sensor Input: ");
Serial.println(sensorValue);
float voltage = sensorValue / 48;
// convert the input value from controller to 12v reading

// print out the value you read:

Serial.print(voltage);
Serial.println(“V”);

if (voltage >= UpperVThreshhold) {

digitalWrite(Relay, HIGH);

Serial.print("Engage discharge procedure: ");
Serial.println(voltage);
float voltage = sensorValue / 48;
do {
//wait for the voltage to drop and KEEP CHECKING
float sensorValue = analogRead(A1);

// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):

Serial.print("Sensor Input: ");
Serial.println(sensorValue);
float voltage = sensorValue / 48;

delay(2000);
Serial.print(UpperVThreshhold);
Serial.print(" ");
Serial.print("Discharge Reading: ");
Serial.println(voltage);
Serial.print("Low threshhold: ");
Serial.println(LowerVThreshhold);

// check if the battery bank has reached it’s minimum voltage!
if (LowerVThreshhold>voltage);
{
break;
}

} while ((float)LowerVThreshhold<(float)voltage);
Serial.print(“Stop!”);

// once voltage is low, turn off the load
digitalWrite(Relay, LOW);

Serial.print("Finish discharge procedure: ");

Serial.println(voltage);

}

delay(5000); /// 5 second delay for easy clock speed

}

float voltage = sensorValue / 48;

How does that convert ADC reading to Volts? The usual formula is Volts = (Vref/1024) * ADC reading.

if (LowerVThreshhold>voltage);

If statements don't end with a semicolon.

Read the how to use this forum sticky (in bold at the top of every topic) to see how to properly post code.

Using auto format (ctrl-t or Tools, Auto Format) would improve the readability of your code.

Thank you everyone for your help! I will fix my if statements and try again .

Also the voltage readying I get from my analog port on the Arduino is actually accurate I discovered from simply dividing it by 48. I can verify this is accurate because I have 2 factory made external shunt volt/amp meters on my project and it displays the same voltage as my Arduino's serial monitor, usually identical to the 0.02v range.

I'll check my next post to make sure I put my code proper! I tried to find a way to do it this post but I could you find the buttons.

float voltage = sensorValue / 48;
do {
//wait for the voltage to drop and KEEP CHECKING
float sensorValue = analogRead(A1);

// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):

Serial.print("Sensor Input: ");
Serial.println(sensorValue);
float voltage = sensorValue / 48;

delay(2000);
Serial.print(UpperVThreshhold);
Serial.print("  ");
Serial.print("Discharge Reading: ");
Serial.println(voltage);
Serial.print("Low threshhold: ");
Serial.println(LowerVThreshhold);

// check if the battery bank has reached it's minimum voltage!
if (LowerVThreshhold>voltage);
{
 break; 
}


} while ((float)LowerVThreshhold<(float)voltage);

Why can’t you properly indent your code?

Why are you declaring a variable inside the body of the do/while statement with the SAME name as one declared outside of the statement? Which one do you think is used in the comparison?

Why are you using a do/while statement, anyway? Unless you understand the differences between while and do/while, AND you need those differences, use a while statement.