Change code to work with 20x4 LCD instead of 16x2

Yes I know there is a 1 pixel gap because of the way these displays are but if you look closely there is a 2 pixel gap instead of a 1 pixel gap between the left channel and the new line of dashes, sorry I don't think I was clear enough on that. thought I would mention it in case it was somehow useful to know in terms of the way the code maybe working. in terms of multiplying the values, what do I change exactly?

I have amended what I said below picture to hopefully make myself clearer.

Try this

 lcd.setCursor(x, 1); // draw first (top) row Left
    if (peaks[x] == 0) {
      lcd.setCursor(x, 1);
      lcd.print("_");  // empty
      lcd.setCursor(x, 0);
      lcd.print("_");  // empty
    }
    else {
    if (peaks[x]>4) {       //after value 8 you need to jump to next row, correct ?
     lcd.setCursor(x, 1);
     lcd.write(8);
     lcd.setCursor(x, 0);  
     lcd.write(2*(peaks[x]-4));
    }
    else {       //if not bigger we only occupy 1 row, correct ?
     lcd.setCursor(x, 1); //position inferior row
     lcd.write(2*peaks[x]);
     lcd.setCursor(x, 0);  // position superior row
     lcd.print("_");  //empty 

    }
    }

YES YES YES! I think you nailed it! first your code got me this...

1 Like

So I replaced the three instances of... lcd.print("_"); // empty with lcd.print(" "); // empty... and we now have this...

1 Like

So I copied and pasted that into the right channel section of the code, corrected the print statements to print on lower 2 rows, changed anywhere it said peaks[x] for peaks[y] and.....


YAY! Thanks so much.

ur welcom, ...good luck man , think on the next project now... and try to make time to follow more tutorials

Definitely Will do, Thanks again.

1 Like

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.