Needed help with troubleshooting my code

This is the code:

 const unsigned long eventInterval1 = 3000;
  const unsigned long eventInterval2 = 6000;
  const unsigned long eventInterval3 = 9000;
  unsigned long previousTime = 0;
  #include <LiquidCrystal.h> //Dołączenie bilbioteki
LiquidCrystal lcd(7, 8, 9, 10, 11, 12); //Informacja o podłączeniu nowego wyświetlacza
#define PIN_YELLOW 6
  #define PIN_GREEN 5
  #define PIN_BLUE 4
  #define PIN_PURPLE 3
  #define PIN_BROWN 2

   
void setup() {
  lcd.begin(16, 2); //Deklaracja typu
  Serial.begin(9600);

    pinMode(PIN_YELLOW, INPUT_PULLUP);
    pinMode(PIN_GREEN, INPUT_PULLUP);
    pinMode(PIN_BLUE, INPUT_PULLUP);
    pinMode(PIN_PURPLE, INPUT_PULLUP);
    pinMode(PIN_BROWN, INPUT_PULLUP);
    delay(200);
}
 
void loop() {
  unsigned long currentTime = millis();
  lcd.begin(16, 2); //Deklaracja typu
  lcd.setCursor(0, 0); //Ustawienie kursora
  if (digitalRead(6) == LOW) {
    lcd.print("     STREAM");
    lcd.setCursor(0, 1);
    lcd.print("    STARTING");
    delay(10000);
    lcd.clear();
  } 
  if(digitalRead(5) == LOW) {
    lcd.print("    CHATTING ");
    lcd.setCursor(0, 1);
    lcd.print("     CAMERA");
    delay(10000);
    lcd.clear();
  }
 if(digitalRead(4) == LOW) {
    lcd.print("    BE RIGHT");
    lcd.setCursor(0, 1);
    lcd.print("      BACK");
    delay(10000);
    lcd.clear();
  }
 if(digitalRead(3) == LOW) {
    lcd.print("     STREAM");
    lcd.setCursor(0, 1);
    lcd.print("     ENDING");
    delay(10000);
    lcd.clear();
  }
   if(digitalRead(2) == LOW) {
    lcd.print("     DISPLAY");
    lcd.setCursor(0, 1);
    lcd.print("     SHARING");
    delay(10000);
    lcd.clear();
  }
    if(currentTime - previousTime = eventInterval1){
  lcd.print("1.STARTING"); //Wyświetlenie tekstu
  lcd.setCursor(0, 1); //Ustawienie kursora
  lcd.print("2.CAMERA"); //Wyświetlenie tekstu
    }
    if(currentTime - previousTime = eventInterval2){
  lcd.clear(); //Ustawienie kursora
  lcd.print("3.BRB"); //Wyświetlenie tekstu
  lcd.setCursor(0, 1); //Ustawienie kursora
  lcd.print("4.ENDING"); //Wyświetlenie tekstu
    }
  if(currentTime - previousTime = eventInterval3){
    lcd.clear(); //Ustawienie kursora
  lcd.print("5.DISPLAY"); //Wyświetlenie tekstu
  lcd.setCursor(0, 1); //Ustawienie kursora
  lcd.print("6.CONCERT"); //Wyświetlenie tekstu
}
previousTime = currentTime
}

And this is the error:


\Desktop\wy_wietlacz\wy_wietlacz.ino: In function 'void loop()':

wy_wietlacz:66:37: error: lvalue required as left operand of assignment

     if(currentTime - previousTime = eventInterval1){

                                     ^~~~~~~~~~~~~~

wy_wietlacz:71:37: error: lvalue required as left operand of assignment

     if(currentTime - previousTime = eventInterval2){

                                     ^~~~~~~~~~~~~~

wy_wietlacz:77:35: error: lvalue required as left operand of assignment

   if(currentTime - previousTime = eventInterval3){

                                   ^~~~~~~~~~~~~~

wy_wietlacz:84:1: error: expected ';' before '}' token

 }

 ^

exit status 1

lvalue required as left operand of assignment


What could be wrong with this? For people wondering trying to help me, I am trying to make it display three different messages on each interval (3000, 6000, 9000) but I am trying to use milis so that the arduino reacts if I press a button.

Use ">=" not "="

At worst, use "==", but never, as you have found out, use "="

But then all three actions would run at the same time right? And I don't want that. I want the first one to turn on at 3000 and turn off when the other one starts. If You know what i am saying

Wrong.

What happened when you tried?

= assigns value
A = B make A the same value as B

== is a comparator
A == B checks of A is the same value as B

ohhh. That's why ok. I'll try now

nothing showed up. As if it was updating constantly. I'll try the == now

Still the same

Add some flags so the first two intervals only trigger once each:

const unsigned long eventInterval1 = 3000;
const unsigned long eventInterval2 = 6000;
const unsigned long eventInterval3 = 9000;
unsigned long previousTime = 0;
#include <LiquidCrystal.h> //Dołączenie bilbioteki
LiquidCrystal lcd(7, 8, 9, 10, 11, 12); //Informacja o podłączeniu nowego wyświetlacza
#define PIN_YELLOW 6
#define PIN_GREEN 5
#define PIN_BLUE 4
#define PIN_PURPLE 3
#define PIN_BROWN 2

bool triggered1 = false;
bool triggered2 = false;

void setup()
{
  lcd.begin(16, 2); //Deklaracja typu
  Serial.begin(9600);

  pinMode(PIN_YELLOW, INPUT_PULLUP);
  pinMode(PIN_GREEN, INPUT_PULLUP);
  pinMode(PIN_BLUE, INPUT_PULLUP);
  pinMode(PIN_PURPLE, INPUT_PULLUP);
  pinMode(PIN_BROWN, INPUT_PULLUP);
  delay(200);
}

void loop()
{
  unsigned long currentTime = millis();
  lcd.begin(16, 2); //Deklaracja typu
  lcd.setCursor(0, 0); //Ustawienie kursora
  if (digitalRead(6) == LOW)
  {
    lcd.print("     STREAM");
    lcd.setCursor(0, 1);
    lcd.print("    STARTING");
    delay(10000);
    lcd.clear();
  }

  if (digitalRead(5) == LOW)
  {
    lcd.print("    CHATTING ");
    lcd.setCursor(0, 1);
    lcd.print("     CAMERA");
    delay(10000);
    lcd.clear();
  }

  if (digitalRead(4) == LOW)
  {
    lcd.print("    BE RIGHT");
    lcd.setCursor(0, 1);
    lcd.print("      BACK");
    delay(10000);
    lcd.clear();
  }

  if (digitalRead(3) == LOW)
  {
    lcd.print("     STREAM");
    lcd.setCursor(0, 1);
    lcd.print("     ENDING");
    delay(10000);
    lcd.clear();
  }

  if (digitalRead(2) == LOW)
  {
    lcd.print("     DISPLAY");
    lcd.setCursor(0, 1);
    lcd.print("     SHARING");
    delay(10000);
    lcd.clear();
  }

  if (!triggered1 && currentTime - previousTime >= eventInterval1)
  {
    triggered1 = true;
    lcd.print("1.STARTING"); //Wyświetlenie tekstu
    lcd.setCursor(0, 1); //Ustawienie kursora
    lcd.print("2.CAMERA"); //Wyświetlenie tekstu
  }
  
  if (!triggered2 && currentTime - previousTime >= eventInterval2)
  {
    triggered2 = true;
    lcd.clear(); //Ustawienie kursora
    lcd.print("3.BRB"); //Wyświetlenie tekstu
    lcd.setCursor(0, 1); //Ustawienie kursora
    lcd.print("4.ENDING"); //Wyświetlenie tekstu
  }
  
  if (currentTime - previousTime >= eventInterval3)
  {
    lcd.clear(); //Ustawienie kursora
    lcd.print("5.DISPLAY"); //Wyświetlenie tekstu
    lcd.setCursor(0, 1); //Ustawienie kursora
    lcd.print("6.CONCERT"); //Wyświetlenie tekstu
    triggered1 = false;
    triggered2 = false;
    previousTime = currentTime;
  }
}

Why do you have lcd.begin(16, 2);
in your void loop?

that is a good question. Deleted it now cause it was in setup too. Probably somehow copied it by mistake

Now we have nothing showing up. After deleting the lcd.begin in the loop it understandably stopped flickering but nothing is showing up until i press a button. The buttons work though

it suddenly started working. Thanks everybody

Maybe adding more screen clearing and cursor setting will help.

Note: I added a "return;" at the end of each button press. This is to go right to the next iteration of loop() to update currentTime. Without that the timing code would see the time jump forward 10 seconds and everything would trigger all at once.

const unsigned long eventInterval1 = 3000;
const unsigned long eventInterval2 = 6000;
const unsigned long eventInterval3 = 9000;
unsigned long previousTime = 0;
#include <LiquidCrystal.h> //Dołączenie bilbioteki
LiquidCrystal lcd(7, 8, 9, 10, 11, 12); //Informacja o podłączeniu nowego wyświetlacza
#define PIN_YELLOW 6
#define PIN_GREEN 5
#define PIN_BLUE 4
#define PIN_PURPLE 3
#define PIN_BROWN 2

bool triggered1 = false;
bool triggered2 = false;

void setup()
{
  lcd.begin(16, 2); //Deklaracja typu
  Serial.begin(9600);

  pinMode(PIN_YELLOW, INPUT_PULLUP);
  pinMode(PIN_GREEN, INPUT_PULLUP);
  pinMode(PIN_BLUE, INPUT_PULLUP);
  pinMode(PIN_PURPLE, INPUT_PULLUP);
  pinMode(PIN_BROWN, INPUT_PULLUP);
  delay(200);
}

void loop()
{
  unsigned long currentTime = millis();

  if (digitalRead(PIN_YELLOW) == LOW)
  {
    lcd.clear();
    lcd.setCursor(0, 0); //Ustawienie kursora
    lcd.print("     STREAM");
    lcd.setCursor(0, 1);
    lcd.print("    STARTING");
    delay(10000);
    lcd.clear();
    return;
  }

  if (digitalRead(PIN_GREEN) == LOW)
  {
    lcd.clear();
    lcd.setCursor(0, 0); //Ustawienie kursora
    lcd.print("    CHATTING ");
    lcd.setCursor(0, 1);
    lcd.print("     CAMERA");
    delay(10000);
    lcd.clear();
    return;
  }

  if (digitalRead(PIN_BLUE) == LOW)
  {
    lcd.clear();
    lcd.setCursor(0, 0); //Ustawienie kursora
    lcd.print("    BE RIGHT");
    lcd.setCursor(0, 1);
    lcd.print("      BACK");
    delay(10000);
    lcd.clear();
    return;
  }

  if (digitalRead(PIN_PURPLE) == LOW)
  {
    lcd.clear();
    lcd.setCursor(0, 0); //Ustawienie kursora
    lcd.print("     STREAM");
    lcd.setCursor(0, 1);
    lcd.print("     ENDING");
    delay(10000);
    lcd.clear();
    return;
  }

  if (digitalRead(PIN_BROWN) == LOW)
  {
    lcd.clear();
    lcd.setCursor(0, 0); //Ustawienie kursora
    lcd.print("     DISPLAY");
    lcd.setCursor(0, 1);
    lcd.print("     SHARING");
    delay(10000);
    lcd.clear();
    return;
  }

  if (!triggered1 && currentTime - previousTime >= eventInterval1)
  {
    triggered1 = true;
    lcd.clear();
    lcd.setCursor(0, 0); //Ustawienie kursora
    lcd.print("1.STARTING"); //Wyświetlenie tekstu
    lcd.setCursor(0, 1); //Ustawienie kursora
    lcd.print("2.CAMERA"); //Wyświetlenie tekstu
  }

  if (!triggered2 && currentTime - previousTime >= eventInterval2)
  {
    triggered2 = true;
    lcd.clear();
    lcd.setCursor(0, 0); //Ustawienie kursora
    lcd.print("3.BRB"); //Wyświetlenie tekstu
    lcd.setCursor(0, 1); //Ustawienie kursora
    lcd.print("4.ENDING"); //Wyświetlenie tekstu
  }

  if (currentTime - previousTime >= eventInterval3)
  {
    lcd.clear();
    lcd.setCursor(0, 0); //Ustawienie kursora
    lcd.print("5.DISPLAY"); //Wyświetlenie tekstu
    lcd.setCursor(0, 1); //Ustawienie kursora
    lcd.print("6.CONCERT"); //Wyświetlenie tekstu
    triggered1 = false;
    triggered2 = false;
    previousTime = currentTime;
  }
}