Brain#

Initializing the Brain Class#

To use Brain methods in your project, start by initializing it as follows:

# Create a new object "brain" with the Brain class.
brain = Brain()

This brain object will be used in all subsequent examples throughout this API documentation when referring to Brain class methods.

Class Methods#

Looks Methods#

print()#

The print(text, sep, precision) method prints text on the screen using the current cursor position.

Parameters

Description

text

The text to print.

sep

Optional. A string to inset between values. This must be written as a keyword argument (sep=). The default is " ".

precision

Optional. The number of decimal places to display when printing simple numbers. This must be written as a keyword argument(precision=). The default is 2.

Returns: None.

# Print the number 1 on the Brain's screen at current
# cursor position.
brain.print(1)

# Print the numbers 1, 2, 3 and 4 on the Brain's screen at
# current cursor position separated by a '-'.
brain.print(1, 2, 3, 4, sep='-')

new_line()#

The new_line() method moves the cursor to a new line.

Returns: None.

clear()#

The clear(color) method clears the Print Console.

Returns: None.

# Print VEXcode on the Print Console.
brain.print("VEXcode")

# Clear the Print Console after 2 seconds.
wait(2, SECONDS)
brain.clear()

set_print_color()#

The set_print_color(color) method sets the text color to be printed in the Print Console.

Parameters

Description

color

A valid ColorType, a hex value, or a web string.

Returns: None.

# Set pen color red using a hex value.
brain.set_print_color(0xFF0000)

Sensing Methods#

timer_reset()#

The timer_reset() method resets the timer’s value.

Returns: None.

timer_time()#

The timer_time(units) method returns the elapsed time.

Parameters

Description

units

A valid TimeUnits type. The default is MSEC.

Returns: The elapsed time in the specified unit.