//if we are on a 1-line display, set line_num to 1st line, regardless of given if (lcd_lines==1){ line_num = 1; } //offset 40 chars in if second line requested if (line_num == 2){ x += 40; }// add the following code for 4 line display if (line_num == 3) { // In fact, line 3 is an extension of the line 1 (beyond the 20 first characters) x += 20; } if (line_num == 4) { // Line 4 is an extension of line 2 x += 60; } //advance the cursor to the right according to position. (second line starts at position 40). for (int i=0; i<x; i++) { commandWrite(0x14); }}