RFID Doorlock with servo and i2c lcd

Hey all,
I'm trying to build a doorlock using a servo, and iv'e adapted a code that was using a relay to use a servo.

now i just want the arduino to write everything it's writing to the serial port, to the i2c lcd instead.

this: https://arduino-info.wikispaces.com/LCD-Blue-I2C - shows how to have it write everything coming from the serial port to the lcd, but i'm not great with C++, and don't know how to either integrate it to the multiple feeds that the code attached has, or what i would really prefer is, to replace writing to the serial with writing to lcd altogether.

Bottom line - please help me convert the attached code so it will write to the lcd insead of the serial port, it's connected like the link above shows.

Thanks!

- (1).cpp (20.4 KB)

Once you have created an instance of the LiquidCrystal_I2C library, you can simply replace Serial.print() with lcd.print() (assuming that you called the instance lcd).

do i not need to use the following before each time?
lcd.clear();
lcd.setCursor(0,0)

do i not need to use the following before each time?

If you want to clear the lcd, and start printing on the first row each time, yes. If not, no.

Roik:
do i not need to use the following before each time?
lcd.clear();
lcd.setCursor(0,0)

If you want to empty the screen before printing, lcd.clear is quick. When you use lcd.clear cursor is also set to top left corner so no need for lcd.setCursor(0,0).
In case you have a static text on first line and only update second line, there is no need to clear lcd, just move cursor to position you want to print. If a long text is replaced with a shorter, add a few spaces at the end to overwrite previous text

Ok, great. so i got the display working and replaced some of the Serial.print with lcd.print(i left debugging and setup for serial).
now i have another problem: i need the lcd to recognize when there are more than 16 characters and drop to the 2 line. i find the following piece that does this:

void loop()
{
int charcount;
boolean secondline;
if (Serial.available()) {
delay(200);
lcd.clear();
charcount = 0;
secondline = false;
while (Serial.available() > 0) {
if (charcount > 15 && secondline == false ) {
lcd.setCursor(0,1);
secondline = true;
}
lcd.write(Serial.read());
charcount++;
}
}
}

Problem is, i don't know how to implement this piece so it will run continuously within the code.
How should i continue?

what i have until now attached

RFIC door lock - no 2nd line drop.cpp (20.5 KB)

Problem is, i don't know how to implement this piece so it will run continuously within the code.
How should i continue?

Create a function to display text on the LCD. Put the logic for showing one line or two in that function. Call that function everywhere you need to show data on the LCD.