Displaying text

The Adafruit library also makes it very easy to display text to the Nokia 5110 LCD. The following code shows how we can display text:

// Display text
display.setTextSize(1);
display.setTextColor(BLACK);
display.setCursor(0,0);
display.println("Hello, world!");

// Display Reverse Text
display.setTextColor(WHITE, BLACK);
display.println(3.14);

// Display Larger Text
display.setTextSize(2);
display.setTextColor(BLACK);
display.print("This is larger text");
display.display();

The setTextSize() function sets the size of the text. In the first example, the text size is set to 1. The setTextColor() function will set the color of the text. Once again, since the Nokia 5110 LCD is a monochrome display, the two options are BLACK or ...

Get Mastering Arduino now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.