Using the Print Console in VEXcode EXP with Python

The Print Console allows the user to display messages, report sensor values, or to present data from VEXcode EXP projects. The Print Console also allows users to save print outputs as a text file.

The Print Console can also be used to display process information, providing visual cues that enable the user to see what is happening in a VEXcode EXP project at a specific moment in time, thereby making a visual connection between the project and the actions of the EXP Robot.

The Print Console needs to have active communication between the VEX EXP Brain and the device being used with VEXcode EXP. This can be accomplished by:

USB Connection

Brain connected to a laptop computer using a USB cable.

Wireless Via Controller

Controller connected to a laptop computer using a USB cable.

Note: Bluetooth communication is unavailable.


How to Open the Print Console

VEXcode EXP Toolbar with the Monitor Display icon highlighted in between the Devices and Help icons.

The Print Console is located in the EXP Monitor Display. To open the Print Console, select the Monitor Display icon next to Help.

Print Console menu is open and shows a blank space for projects to print information and text to.

The Monitor Display will open once selected. The Print Console is at the right side.


How to Use the Print Console in a Project

Commands that Trigger the Print Console

VEXcode EXP Python Toolbox with the Print commands highlighted inside the Looks category.

Print commands are located in the Look category of commands and are used in a VEXcode EXP project in order to trigger the Print Console.

These commands print words, numbers, reported values from variables, values reported from a sensor or device, or clear the console.

The Help feature in VEXcode EXP provides additional information on these and other commands.

See this article for information on how to access the Help feature.

Using Print Commands with the Print Console

# Begin project code
print("VEXcode")
print("Print Console")

Use print commands in a VEXcode EXP project to print a message, or display data in the Print Console.

To use the print commands, select the command and add it to a project.

Then, type the text to be printed inside the quotation marks within the parentheses.

Note: You can also add sensor or variable commands inside the parenthesis to print data. See examples in the 'Examples using the Print Console' section. 

VEXcode EXP Toolbar with the Run and Stop icons highlighted together.

Download the project to the EXP Robot Brain and Select "Run". See this article on downloading and running a Python project. 

Print Console menu is open and shows the printed messages from the previous Python project. The first message reads VEXcode, and on the line below the second message reads Print Console.

Once “Run” is selected, the project will run and the colored text or programmed values will be printed to the Print Console as dictated by the VEXcode EXP project.

Note: Python creates a new line by default after each print command.

# Begin project code
print("VEXcode","Print Console")

Print Console menu is open and shows the printed message from the previous Python project. The message is all on one line, and it reads VEXcode Print Console.

You can print multiple values on a single line by adding multiple messages or commands inside the parentheses of the print command, and separating them with commas as shown on the image on the left.

# Begin project code
print("VEXcode ",end="")
print("Print Console")

Print Console menu is open and shows the printed message from the previous Python project. The message is all on one line, and it reads VEXcode Print Console.

Or, you can utilize the end parameter to print multiple values to a single line, as shown in this image.


Printing in Color in the Print Console

# Begin project code
print("\033[31m")
print("VEXcode")

You can set the color of the text being printed by using a color code with a print command in VEXcode EXP.

To use a color code with a print command, add the escape sequence ("\033") and the color code inside the print command, as shown on the left.

The following are a few examples of color codes.

  • [31m - Red
  • [32m - Green
  • [34m - Blue

See the complete list of color codes in the Help Feature for the print command. See this article for information on how to access the Help feature.

VEXcode EXP Toolbar with the Run and Stop icons highlighted together.

Download the project to the EXP Robot Brain and Select "Run". See this article on downloading and running a Python project. 

Print Console menu is open and shows the printed message from the previous Python project. The message is all on one line, and in red colored text it reads VEXcode.

Once “Run” is selected, the project will run and the colored text or programmed values will be printed to the Print Console as dictated by the VEXcode EXP project.


Clear Rows in the Print Console

Print Console menu is open and the Clear button is highlighted below.

There are two ways to clear all information from the Print Console. The first way to completely clear all text is to select the “Clear” button on the bottom left of the Print Console.

# Begin project code
print("Hello")
wait(3, SECONDS)
print("\033[2J")

Another way to clear the Print Console is to use the Console Clear print command highlighted in the image on the left. Add this command to remove all of the lines in the Print Console.

In this project, “Hello” will print on the Print Console. After 3 seconds, the console will be cleared.


Save from the Print Console

Print Console menu is open and the Save button is highlighted below.

It is easy to save information from the Print Console onto your device.

Select “Save” on the bottom of the Print Console to save all text as a .txt file.

Saved Print Console file is shown in the device's Downloads folder.

Once you select the “Save” button, the file will automatically save to the Downloads folder on your device as a .txt file.

Note: The file does not save printed colors.


Example Projects Using the Print Console

Report Variable Values and Data in a Project

The Print Console can be used to report variable values at discrete moments within a project.

# Begin project code
my_variable = 0

# Print Console values in a loop
while True:
if brain.buttonLeft.pressing():
my_variable += 1

# The `end=""` parameter allows multiple `print` commands to
# print to the same line
print("Increased Variable: ", end="")
print(my_variable)

if brain.buttonRight.pressing():
my_variable -= 1

# The `end=""` parameter allows multiple `print` commands to
# print to the same line
print("Decreased Variable: ", end="")
print(my_variable)

wait(0.1, SECONDS)

Print Console is shown with the output messages from the previous Python project. The messages show the variable counting up to 3 and then back down to 0, one value at a time.

Use the Print Console to print the value of “myVariable."

In the project on the left, the Print Console displays variable values when the Brain buttons are pressed. The variable increases when the 'left' button is pressed, and decreases when the 'right' button is pressed.


Report Sensing Values and Data in a Project

The Print Console can be used to report sensor data at discrete moments within a project.

# Begin project code

# Calibrate the Drivetrain before starting
# This resets the heading and rotation values
calibrate_drivetrain()

drivetrain.turn(RIGHT)

while brain.timer.time(SECONDS) < 10:
# The `end=""` parameter allows multiple `print` commands
# to print values on the same line
print("Timer: {:.1f}".format(brain.timer.time(SECONDS)), " ", end="")
print("Rotation: {:.1f}".format(drivetrain.rotation()))

drivetrain.stop()

Print Console is shown with the output messages from the previous Python project. The messages show the timer and rotation values counting up over time until the timer reaches 10 seconds.

The data captured by the Print Console allows the user to see valuable information about project processes including EXP Robot sensor information. When the print command is triggered, it can be programmed to display information captured in the moment.

In the project on the left, the Print Console displays information reported by the Inertial Sensor built into the EXP Brain as prescribed by the Look and Sensing commands within the project. This information includes changes that the Inertial Sensor captures at discrete moments while the project is running: time in seconds and the rotation of the EXP BaseBot in degrees.

Note: The project in this example uses the BaseBot (Drivetrain, 2-motor) template.

For more information, help, and tips, check out the many resources at VEX Professional Development Plus

Last Updated: