O'Reilly logo

Mastering Arduino by Jon Hoffman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required