Getting 'inf' in all values of sensor readings in serial monitor

so i am getting inf in all the sensor data , for a sec it shows the data then it says "inf". i am using two flow meters based on hall effect sensors (YF -S201). i want to show the total water that went through sensor 1 and sensor 2 then show the fuel left . ps im making a fuel level indicator
here' my code

int X;
int Y;
int A;
int B;
float WATER1 = 0;
float WATER2 = 0;
float TIME1 = 0;
float TIME2 = 0;
float FREQUENCY1 = 0;
float FREQUENCY2 = 0;
float FUEL1 = 0;
float FUEL2 = 0;
float TOTAL1 = 0;
float TOTAL2 = 0;
float LS1 = 0;
float LS2 = 0;
const int input1 = 2;
const int input2 = 3;
const long interval = 1000;
unsigned long previousMillis = 0;
void setup()
{                                     
Serial.begin(9600);
}
void loop()
{
X = pulseIn(input1, HIGH);
Y = pulseIn(input1, LOW);
A = pulseIn(input2, HIGH);
B = pulseIn(input2, LOW);
TIME1 = X + Y;
TIME2 = A = B;
FREQUENCY1 = 1000000/TIME1;
FREQUENCY2 = 1000000/TIME2;            
WATER1 = FREQUENCY1/7.5;
WATER2 = FREQUENCY2/7.5;
LS1 = WATER1/60;
LS2 = WATER2/60;
unsigned long currentMillis = millis();

if(FREQUENCY1 >= 0 && FREQUENCY2 >= 0)  
{
if((isinf(FREQUENCY1)) && (isinf(FREQUENCY2)))  
{
Serial.print("TOTAL1:");
Serial.print( TOTAL1);
Serial.print(" L");
Serial.print("TOTAL2:");
Serial.print( TOTAL2);
Serial.println(" L");
}
else 
 { TOTAL1 = TOTAL1 + LS1;

Serial.print("TOTAL1:");
Serial.print( TOTAL1);
Serial.println(" L");
TOTAL2 = TOTAL2 + LS2;
Serial.print("TOTAL2:");
Serial.print( TOTAL2);
Serial.println(" L");
 }

}{delay(500);}
}

i have also attached the serial monitor screenshot
i have 2 days to fix this . THANK YOU for your help from the start.

OUTPUT .png

two days?

what is so magical about 2 days?

Oh, you mean that is when this class assignment is due?
:slight_smile:

Perhaps it's because each one of these will block until the end of the pulse occurs or the time-out occurs:

X = pulseIn(input1, HIGH);
Y = pulseIn(input1, LOW);
A = pulseIn(input2, HIGH);
B = pulseIn(input2, LOW);

Probably need to design a different way of doing whatever you are doing.

Paul

"Inf" suggests that you are dividing by zero.

How is this line supposed to work?

TIME2 = A = B;

ieee488:
two days?

what is so magical about 2 days?

Oh, you mean that is when this class assignment is due?
:slight_smile:

yeah i had a submission. its done tho i used interrupt functions