Execute if cicles even if it is not satisfy.

Dear, I'm a new with arduino.

I'm developping a sketch that should manage an air fun at home in a specific condition.

So, the sketch work well on Arduino UNO. i tested it for many days (breadbord).

Few days ago i got an ARDUINO MICRO. I did modify just few unimportant things (name of some variables and some string text).

What happen now?

In the sketch are present many if - do - while.

At certain moment i ask to check if a BT_Setting (button) is pushed. in this case do what inside if.... But the sketch execute what inside "if" in any case.

I checked for mistake like formatting, wrong variable names atc, but all is fine

The problematic if is:

BT_Setting = digitalRead(Set_Bt);
if (BT_Setting == LOW)
{
XXXXXX
XXXXXX
XXXXX
}

This (belove) is the line before and after and attached you can find the whole sketch.

............................

////////////////////////////// AUTOMODE LOW ////////////////////////
if (autoMode == LOW) // mode=low --> Relay is OFF
{
Rel_OFF (); //need to shiwtch relay off when return from Smoke-mode
// Enable Manual START if request by operator

//////////////////////////////////////////////////////////

BT_Setting = digitalRead(Set_Bt);
if(BT_Setting == LOW)
{
lcd.init(); // POINT of ERROR
lcd.setCursor(1, 0);
lcd.print("BT set ");
lcd.print(BT_Setting);
delay (5000);
Delay_time (); // Check for manual ON loop
Rel_OFF (); //call subtoutine OFF
autoMode = LOW; //set to OFF
Time_ref = millis();
Millis_Min ();
lcd.init(); // POINT of ERROR
lcd.setCursor(1, 0);
lcd.print("ERRORE ");
}
Toff_Last = ((((Toff + Time_ref) - (millis())) / TM_conv) + 1);
Serial.println((String)"RELAY OFF, it goes ON into " + Toff_Last + " min");
lcd.init(); // initialize the lcd
lcd.setCursor(3, 0);
lcd.print("RELAY OFF:");
lcd.setCursor(0, 1);
lcd.print("ON into ");
lcd.print(Toff_Last);
lcd.print(" min");
delay (T_step);

..................

As i sayd before in the sketch are present many "IF" and just 3, related to this BT_Setting give me haedacke.

I really can't find the problem, please help!!!!!

Thanks for your help

ARD1_Aria_V7_LAST.ino (18.4 KB)

Your code doesn't compile, I get:

sketch_apr08a.ino: In function 'void setup()':
sketch_apr08a:70: error: 'class LiquidCrystal_I2C' has no member named 'init'
sketch_apr08a.ino: In function 'void loop()':
sketch_apr08a:153: error: 'class LiquidCrystal_I2C' has no member named 'init'
sketch_apr08a:165: error: 'class LiquidCrystal_I2C' has no member named 'init'
sketch_apr08a:188: error: 'class LiquidCrystal_I2C' has no member named 'init'
sketch_apr08a:222: error: 'class LiquidCrystal_I2C' has no member named 'init'
sketch_apr08a:239: error: 'class LiquidCrystal_I2C' has no member named 'init'
sketch_apr08a:255: error: 'class LiquidCrystal_I2C' has no member named 'init'
sketch_apr08a:273: error: 'class LiquidCrystal_I2C' has no member named 'init'
sketch_apr08a:290: error: 'class LiquidCrystal_I2C' has no member named 'init'
sketch_apr08a:302: error: 'class LiquidCrystal_I2C' has no member named 'init'
sketch_apr08a.ino: In function 'void Smoker_mode()':
sketch_apr08a:335: error: 'class LiquidCrystal_I2C' has no member named 'init'
sketch_apr08a:357: error: 'class LiquidCrystal_I2C' has no member named 'init'
sketch_apr08a:386: error: 'class LiquidCrystal_I2C' has no member named 'init'
sketch_apr08a.ino: In function 'void Delay_time()':
sketch_apr08a:413: error: 'class LiquidCrystal_I2C' has no member named 'init'
sketch_apr08a:438: error: 'class LiquidCrystal_I2C' has no member named 'init'
sketch_apr08a.ino: In function 'void Delay_Smoke()':
sketch_apr08a:469: error: 'class LiquidCrystal_I2C' has no member named 'init'
sketch_apr08a:500: error: 'class LiquidCrystal_I2C' has no member named 'init'
'class LiquidCrystal_I2C' has no member named 'init'

How are your buttons wired? Have you tried writing a sketch just to test your buttons?