K
K
kgaudium2019-08-12 04:53:10
Arduino
kgaudium, 2019-08-12 04:53:10

Why doesn't IF checking work in arduino?

I want to write a check: if the data from the sensor is equal to the previous data, then the LED is on without blinking and an error message is displayed, but no matter how I tried to do it, nothing changed: when the module was turned off, the message was not sent, the LED blinked, and I went into a binge . Here is the code:

void setup() {
 
 while (!pressure.begin()){
    Serial.println("Modules init fail\nRetrying");
    analogWrite(10, 150);
    delay(1000);
 }
 analogWrite(10, LOW);
 Serial.println("Modules init success");

 
 Serial.println("BMP180's t°; BMP180's mBar; time");
}
 
void loop() {
  char status;
  double p180T,p180P,p0,a,b20t,p180T_if;

  analogWrite(10, 150);
  status = pressure.startTemperature();          // Считывание показания
  if(status!=0){                                 // Если значение status не 0, выполняем следующию команду.
     delay(status);                              // Ждем    
     status = pressure.getTemperature(p180T);}   // Полученые показания, сохраняем в переменную p180T
     
  status = pressure.startPressure(3);            // Считывание показания
  if(status!=0){                                 // Если значение status не 0, выполняем следующию команду.
    delay(status);                               // Ждем
    status = pressure.getPressure(p180P,p180T);} // Полученные показания, сохраняем в переменную p180P

 if (p180T != (p180T_if,10)){
   p180T_if = p180T;
   Serial.println();
   Serial.print(p180T,10); //max: 19
   Serial.print("; ");
   Serial.print(p180P,10); //max: 14
   Serial.print("; ");
   Serial.print(p180T_if);
   Serial.print("; ");
   Serial.print(p180T);
   Serial.print("; ");
  
   analogWrite(10, LOW);
   delay(1000);}
 else{
   analogWrite(10, 150);
   Serial.print("Pressure module disconnected");
   delay(1000);
 }
}

I cut it down a bit and removed everything off topic, if you need the full code - write.
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
jcmvbkbc, 2019-08-12
@jcmvbkbc

if (p180T != (p180T_if,10))

This place must have meant something else. Now it's written here if (p180T != 10).

S
semen-pro, 2019-08-27
@semen-pro

Declare the status as Then it will be declared once and will be stored permanently at the beginning of RAM

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question