Flashing light with LCD display. Display flickers

Greetings,
I am new to arduino and coding and was wondering if someone could give some guidance on the code I inserted below. I am making a box which lights a single Led after a button press with patterns using PWM signal. The light portion is working as planned but when using a 1602A with an I2C breakout board, I get a flickering effect on the display with each condition (except when the LED is off.) I know that I should separate the code somehow to run the display once and wait for a button press but I dont know how. Any help would be greatly appreciated!

GusSpookyDisplay.ino (2.8 KB)

Hello ShelledWalnuts

Delete all lcd.clr() function calls in the unknown sketch.

You are printing the text with a very small interval

Try something like this:

// Global
  unsigned long prevMillis = 0;

  if (counter == 1)
  {
    if((millis() - prevMillis) > 1000) // Update every 1 s.
    {
      flickerOn = true;
      flickerOn2 = false;
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print(" BAD  BULB ");
      lcd.setCursor(0,1);
      lcd.print("   Option # 1   ");
      prevMillis = millis();
    }
  }

That did it!!!! Thanks so much!

This worked! Thanks so much!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.