Bluetooth Connection in other screens

You have two possibilities ...

  • Your Arduino is still sending alerts
  • Your app is still responding to old alerts.

I notice in your Arduino code that you might be skipping incoming bytes with value 13 in this code sequence, expecting alternate lights and alerts values, instead of single values that need to be examined to see if they are a light or an alert value.

 
  if(Serial2.available()){
  
    //Room1 Lights(Apps)
    lights = Serial2.read();
    if(lights == 1) digitalWrite(LedR1, HIGH);
    if(lights == 2) digitalWrite(LedR1, LOW);
    if(lights == 3) digitalWrite(LedR2, HIGH);
    if(lights == 4) digitalWrite(LedR2, LOW);
    if(lights == 5) digitalWrite(LedR3, HIGH);
    if(lights == 6) digitalWrite(LedR3, LOW);
    if(lights == 7) digitalWrite(LedR4, HIGH);
    if(lights == 8) digitalWrite(LedR4, LOW);
    if(lights == 11) digitalWrite(LedBath, HIGH);
    if(lights == 12) digitalWrite(LedBath, LOW);
  }

  if(Serial2.available()){
      alarm = Serial2.read();
      if(alarm == 13)buzzer_mode = false;
      lastButtonState = 0;
  }

To distinguish between the two cases, add a logger to the place where messages arrive in your Clock Timer.

Here are 3 sample loggers ...

1 Like