Rotating text

We can also rotate text. The following code shows how to do this:

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

The setRotation() function will rotate the text counterclockwise. A value of 1 will rotate the text 90 degrees counterclockwise. Values of 2 and 3 can also be used to rotate the text at 180 and 270 degrees. The following photograph shows how the text will look when this code is run:

Notice that the text will wrap to a new line if it is longer than what can be displayed on a single line.

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.