arduino uno with lcd 1602A is flickering and flashing

i have connected my LCD with a tut from here on the forum

i made a code with single line text showing and second line scrolling

if i test it online with circuits.io it works perfect but in real life it sucks

#include<LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(0, 1, 8, 9, 10, 11);

String txtsc,txtnosc;
void setup(){
  txtnosc="   Lego  Shop   "; //first line of text without scroll
  txtsc="  *25%  Korting*   ";  //second line of text with scroll
  lcd.begin(16, 2);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print(txtnosc);
}

void loop(){

          lcd.setCursor(0,1);
           txtsc=ScrollTxt(txtsc);
           lcd.print(txtsc);
}

String ScrollTxt(String txt){
 return txt.substring(1,txt.length()) + txt.substring(0,1);
}

youtube video of the screen

can someone tell me what im doing wrong or whats wrong at all ?

Add a delay()

Probably when you simulated it, the simulation was running so slowly that you could see the scrolling. The suggestion above of a delay in the loop, say of 1000 mS would help. There is another problem. The String txtsc has a length of 19 characters. Since the display is 16 characters wide, something is going to be truncated and/or overflow and cause a mess.

oke delay added that slows it only thing now is that there are all kind of characters on the screen but not the text i added in the code

someone a idea ?

evinc: oke delay added that slows it only thing now is that there are all kind of characters on the screen but not the text i added in the code

someone a idea ?

Check your connections. Or give a picture so we can see how you have it hooked up. You may have it wired up wrong.

thanks for helping :slight_smile: i edit my code and change some things now it works as i like :slight_smile:

its not the perfect code but it works for me :slight_smile:

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int i=0;

void setup() {
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("   Lego  Shop   ");
  delay(2000);
  // clear the screen
  //lcd.clear();
}
void loop() 
 {
  for (int i=16; i > 0; i--)
{
  lcd.setCursor(0,0);
  lcd.print("   Lego  Shop   ");
  lcd.setCursor(i, 1);
  lcd.print(" 25%  Korting  ");
  delay(250);
 }
 delay (2500);
  lcd.setCursor(0,0);
  lcd.print("   Lego  Shop   ");
  lcd.setCursor(i, 1);
  lcd.print("                ");
  delay (100);
for (int i=16; i > 0; i--)
{
  lcd.setCursor(0,0);
  lcd.print("   Lego  Shop   ");
  lcd.setCursor(i, 1);
  lcd.print(" Op City Sets  ");
  delay (250);
}
delay (2500);
 lcd.setCursor(0,0);
  lcd.print("   Lego  Shop   ");
  lcd.setCursor(i, 1);
  lcd.print("                ");
  delay (100);
  {
  
}
 }

video of the result
Video of the result