Answer the question
In order to leave comments, you need to log in
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);
}
}
Answer the question
In order to leave comments, you need to log in
if (p180T != (p180T_if,10))
if (p180T != 10)
.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question