#include <LiquidCrystal.h>
byte lcd_lines = 4; //Number of lines on the lcd
byte lcd_col = 20; //Number of columns
String empty_line = ""; //Empty string to clear a display's line
LiquidCrystal lcds(12, 13, 10, 9, 8, 7);
LiquidCrystal lcd(12, 11, 10, 9, 8, 7); //Define RS, E, D4, D5, D6, D7 display pins
void setup() {
//Makes the empty line according with the display size
for (int i = 0; i < lcd_col; i++){
empty_line += " ";
}
//Starts the LCD and serial comunication
lcds.begin(16, 4);
lcd.begin(lcd_col, lcd_lines);
Serial.begin(115200);
}
void loop() {
PrintD("Oh shit, here we go again! So lets see how much crap we can fit on this screen, of course the limit should be of eighty characters and for some reason this shit is skipping lines. Okay, problem solved and this thing still looks hideous like the creator. I think that's it, so farewell, and thank you for the fishes.");
delay(3000);
PrintD("Let's do some good shit with this code. Weeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
delay(1000);
lcds.print("Holy shit!!");
lcds.setCursor(0,1);
lcds.print("It's working");
}
void PrintD(String C0){
//Prints caractee by caracter and tries to avoid break words
byte l = 0; //Display line position
byte col = 0; //Display column position
byte count0 = 0; //counter for the word lenght
byte change = 0; //
lcd.clear(); //Clears LCD display
for(int i = 0; i<C0.length(); i++){
if(C0[i] == 0x20){ //if caracter == "espace"
count0 = 0; //set counter 0
int j = i; //set relative string index to current index
//increase count &index until find the and of string or find "space"
do{
j++;
count0++;
}while(j < C0.length() && C0[j] != 0x20);
int rem = lcd_col - col;
if(rem < count0 && count0 < lcd_col){
l++;
col = 0;
i++;
change++;
}
}
if(col == lcd_col){ //if column was exceeded the new line is started
col = 0;
l++;
change++;
}
if(l == lcd_lines){ //if the line is beyond the limits waits and clear the dispay
l = 0;
col = 0;
delay(1000);
lcd.clear();
}
if(change != 0){
lcd.setCursor(col, l);
change = 0;
}
lcd.print(C0[i]);
col++;
delay(30);
}
}