I2C Display using HD44780 20x4 with Funduino LCM1602 piggy backed I2C board

Here is the code I am having issues with ( I want to learn and understand why/what is happening with the display)
Basically most of the code came from Droneworkshop but I’ve had to heavily change it to get to work with my display and of course using platformio.
This line ALWAYS throws up an error at the i2c_addr?
//LiquidCrystal_I2C lcd(i2c_addr, en, rw, rs, d4, d5, d6, d7, bl, POSITIVE);
The code below is working BUT in the scrolling loop the characters re-appear at line 2 (the third line on the lcd screen?)
Please can anyone tutor me as to why?

/*
  Title: Project to display Temperature on LCD Display with I2C Interface
  Sensor: GYTMP102
  Date: 03/11/2023 
  Version:01
  Author: D. Calland (With help from more experienced contributors)
  Anyone can use this code if they wish to!
*/

//Include Required Libraries
#include <Arduino.h> //Platformio inserted
#include <Wire.h> //Arduino Header File for I/O
#include <LiquidCrystal_I2C.h> //Find in Platformio Libraries gets appended to platformio.ini

//Define LCD Pinout associated with I2C board add on
int en=6, rw=5, rs=4, d4=11, d5=12, d6=13,d7=14, bl=15; //(really doesn't do anything to my display)

//Define I2C Address (I know its 0x27)
//#define i2c_addr = 0x27;
LiquidCrystal_I2C lcd(0x27,20,4); //(Only thing I've found that works)

//LiquidCrystal_I2C lcd(i2c_addr, en, rw, rs, d4, d5, d6, d7, bl, POSITIVE); Tried this and always threw up an error in not recognising i2c_addr 

void setup() // put your setup code here, to run once:
             
{ //Set display type as 20 char, 4 rows
  lcd.init();
  lcd.backlight();
  lcd.begin(20,4);
}

void loop()
{
 while(1){ lcd.begin(20,4); 
  // put your main code here, to run repeatedly:
  //Demo 1 - flash the backlight
  lcd.setCursor(0,0);
  lcd.print("Backlight Demo");
  lcd.setCursor(0,1);
  lcd.print("Flash 4 Times");
  delay(2000);
  lcd.clear();

  //Flash 4 times counter
  for (int i = 0; i < 4; i++)
  {
    lcd.backlight();
    delay(500);
    lcd.noBacklight();
    delay(500);
  }

  //Turn backlight back on
  lcd.backlight();
  //Demo 2 - scroll
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Scroll demo -");
  delay(500);
  //Set the display to automatically scroll
  lcd.autoscroll();
  //Print from 0 to 9:
  for (int thisChar = 0; thisChar < 10; thisChar++)
  {
    
    lcd.setCursor(0,0);
    lcd.print(thisChar);
    delay(2000);
  }
  lcd.clear();
  //Turn off automatic scrolling
  lcd.autoscroll();
  
  delay(1000);
 }
}

Thanks maxgerhardt for the edited response…doh! Didn’t spot that :slight_smile:
The code below is working and displaying temperature on my LCD 20x4 screen but not without some issues I want to understand.
1.while(!Serial) {}
Serial.begin(9600); does nothing to the operation of the board as far as I can tell. See my comment in the code.
2) lcd.println(" Another Value"); does not display?

Apart from the above I have it all working successfully, but I’d like to fully understand the issues I’m seeing first before progressing onto my next steps of integrating more sensor types.

Thank you as always for any help, much appreciated.
/*
Title: Project to display Temperature on LCD Display with I2C Interface
Sensor: GYTMP102
Date: 03/11/2023
Version:01
Author: D. Calland (With help from more experienced contributors)
Anyone can use this code if they wish to!
*/

//Include Required Libraries
#include <Arduino.h> //Platformio inserted
#include <Wire.h> //Arduino Header File for I/O
#include <LiquidCrystal_I2C.h> //Find in Platformio Libraries gets appended to platformio.ini

/*
Read the temperature from an LM75-derived temperature sensor, and display it
in Celcius every 250ms. Any LM75-derived temperature should work.
*/
#include <Temperature_LM75_Derived.h>//Find in Platformio Libraries gets appended to platformio.ini

//Define LCD Pinout associated with I2C board add on
int en=6, rw=5, rs=4, d4=11, d5=12, d6=13,d7=14, bl=15; //(really doesn’t do anything to my display)

//Define I2C Address (I know its 0x27 by using Detect I2C Address code)
LiquidCrystal_I2C lcd(0x27,20,4);

void setup() // put your setup code here, to run once:

{ //Set display type as 20 char, 4 rows
lcd.init();
lcd.backlight();
lcd.begin(20,4);
/*
This code has no effect at all to the operation of the LCD display
is this because I have the display directly connected to the dedicated I2C
pins on the Arduino R3 board and not the analogue pins A4, A5? Any Serial commands I use don’t seem to do anything?

while(!Serial) {}
Serial.begin(9600);
*/

Wire.begin();
}

void loop()
{
while(1){
lcd.begin(20,4);
lcd.setCursor(0,0);

// The Generic_LM75 class will provide 9-bit (±0.5°C) temperature for any
// LM75-derived sensor. More specific classes may provide better resolution.
Generic_LM75 temperature;
lcd.print("Temperature (degC) “);
lcd.setCursor(0,1);
lcd.print(” Value = ");
lcd.print(temperature.readTemperatureC());
delay(5000);}
lcd.println(“Another Value”); //Nothing appears on the display?
delay(5000);}

}