How to display text on the screen of an EV3 brick with Python Pro Preview

Have you noticed when some programs are either loading or executing, they display text on the screen that tells you what is happening? Many programmers add a message line before every operation, where they say what their program is doing.

This way, they can easily find a problem if such appears. This is called debugging and we will learn how to apply it by printing messages on the brick display.

To access the full video please subscribe to FLLCasts.com

Subscribe

  • #1553
  • 06 Mar 2020

The command for printing text is ev3.screen.draw_text() and it requires three input parameters:

  1. X coordinate - shows how far to the right of the left side of the display we want the text to be.
  2. Y coordinate - shows how far down from the upper side of the display we want the text to be.
  3. Text or a number, that you wish to print on the screen. If the text or number IS NOT a variable, then they must be placed in parentheses;

Here's an example of how you can output the message "thinking" on the screen for 5 seconds:

# Create your objects here.
ev3 = EV3Brick()

# Write your program here.
ev3.screen.draw_text(4050"thinking")
wait(5000)

Upon execution of the program, the brick display should look something like this:

content picture

Here the text is set to appear at 40 pixels to the right, which is why it appears to be at the center of the screen. Furthermore, the text is set to be 50 pixels down.

Removing everything from the screen

If you wish to clear the displayed text from the screen, you can use the following command:

ev3.screen.clear()

This command clears the entire display.

Courses and lessons with this Tutorial

This Tutorial is used in the following courses and lessons

Image for Python with LEGO Mindstorms EV3 - Level 1
  • 74
  • 28:18
  • 114