Robot-Specific Blocks#

Introduction#

The 123 Playspace Playground features blocks exclusive to the virtual 123 Robot, including blocks for the robot’s Drivetrain, LED, speaker, actions, Eye Sensor, and Gyro Sensor.

All standard VEXcode VR Blocks are available for use in the 123 Playspace Playground.

Below is a list of all available Playground-specific Blocks:

Drivetrain - Move and turn the robot.

  • Actions

    • drive - Drive the robot forward or in reverse continuously.

    • drive until - Drive the robot until a specified condition is met.

    • drive for - Drive the robot forward or in reverse for a specific distance.

    • turn - Turn the robot right or left continuously.

    • turn for - Turn the robot right or left for a specified amount of degrees.

    • turn to heading - Turn the robot to a specific heading.

    • stop driving - Stops all robot movement.

  • Settings

  • Values

    • drive is done? - Returns a Boolean indicating whether or not the robot is done driving.

    • drive heading - Returns the drivetrain’s heading in degrees.

Sound - Play built-in sounds through the 123 Robot’s speaker.

  • play sound - Plays one of the robot’s built-in sound effects.

LED - Control the 123 Robot’s center LED.

  • glow - Sets the color of the LED light.

Actions - Make the 123 Robot perform preset behaviors.

  • act - Acts out different emotions.

Sensing - Read values from the 123 Robot’s sensors.

Drivetrain#

Actions#

drive#

The drive block moves the robot in the specified direction. This is a non-waiting block, meaning it runs continuously until another Drivetrain block interrupts it or the project stops.

unidad [adelante v]

Parameters

Description

direction

Drives the robot in one of the following directions:

  • forward
  • reverse

Example

cuando empezó
[Drive for 2 seconds.]
unidad [adelante v]
esperar (2) segundos
deja de conducir

drive until#

The drive until block is used to move the robot until a specified condition is met.

Conducir [adelante v] al [objeto v]

Parameters

Description

direction

Drives the robot in one of the following directions:

  • forward
  • reverse

condition

The condition that stops the robot:

  • object - The Eye Sensor detects an object.
  • crash - The robot crashes into another object.
  • line - The Line Detector detects a line underneath the robot.

Example

cuando empezó
[Reverse after a crash.]
Conducir [adelante v] al [choque v]
conducir [atrás v] por (1) [pasos v]

drive for#

The drive for block is used to move the robot for a specified distance.

conducir [adelante v] por (1) [pasos v]

Parameters

Description

direction

Drives the robot in one of the following directions:

  • forward
  • reverse

distance

The distance, as an integer or decimal, that the robot will move, measured in units.

unit

The unit of measurement, which can be one of the following:

  • steps - One square on a 123 field.
  • mm - millimeters

Example

cuando empezó
[Drive back and forth.]
conducir [adelante v] por (3) [pasos v]
conducir [atrás v] por (3) [pasos v]

turn#

The turn block turns the drivetrain continuously left or right. This is a non-waiting block, meaning the drivetrain will keep turning until another Drivetrain block runs or the project stops.

turno [derecha v]

Parameters

Description

direction

The direction the robot will turn:

  • left
  • right

Example

cuando empezó
[Turn for 2 seconds.]
turno [derecha v]
esperar (2) segundos
deja de conducir

turn for#

The turn for block turns the drivetrain left or right for a specific number of degrees.

girar [derecha v] por (90) grado

Parameters

Description

direction

The direction the robot will turn:

  • left
  • right

angle

The angle, as an integer or decimal, at which the robot turns, ranging from -360 to 360 degrees.

Example

cuando empezó
[Turn left, then turn around to the right.]
girar [izquierda v] por (90) grado
girar [derecha v] por (180) grado

turn to heading#

The turn to heading block turns the drivetrain to face a specific heading.

girar hacia el rumbo (90) grados

Parameters

Description

heading

The absolute heading the drivetrain will turn to, from -360 to 360 degrees.

Example

cuando empezó
[Turn to face the cardinal directions.]
girar hacia el rumbo (90) grados
esperar (2) segundos
girar hacia el rumbo (180) grados
esperar (2) segundos
girar hacia el rumbo (270) grados
esperar (2) segundos
girar hacia el rumbo (0) grados
esperar (2) segundos

stop driving#

The stop driving block immediately stops all movement of the drivetrain.

deja de conducir

Parameters

Description

This block has no parameters.

Example

cuando empezó
[Stop driving after 4 seconds.]
unidad [adelante v]
esperar [4] segundos
deja de conducir

Settings#

set drive timeout#

The set drive timeout block sets a time limit for how long a Drivetrain block will wait to reach its target. If the robot cannot complete the movement within the set time, it will stop automatically and continue with the next block.

Note: The Drivetrain’s time limit is used to prevent Drivetrain blocks that do not reach their target position from stopping the execution of other blocks in the stack.

Establezca el tiempo de espera de la unidad en (1) segundos

Parameters

Description

time

The maximum number of seconds a Drivetrain block will run before stopping and moving to the next block.

Example

When started, limits drive time to 1 second and then turns 90 degrees.#
cuando empezó
[Turn right after driving for 1 second.]
Establezca el tiempo de espera de la unidad en (1) segundos
conducir [adelante v] por (1000) [mm v]
girar [derecha v] por (90) grado

set drive heading#

The set drive heading block sets the robot’s current heading to a specified value.

establecer el rumbo de la unidad a (0) grados

Parameters

Description

heading

The heading value to assign, in degrees.

Example

cuando empezó
[Face the new 0 degree heading.]
establecer el rumbo de la unidad a (90) grados
girar hacia el rumbo (0) grados

Values#

drive is done?#

The drive is done? block returns a Boolean indicating whether the drivetrain is not moving.

  • True - The drivetrain is not moving.

  • False - The drivetrain is moving.

Note: This block detects movement only when it is caused by the drive for, drive until, turn for, or turn to heading blocks.

<¿La unidad está lista?>

Parameters

Description

This block has no parameters.

Example

cuando empezó
[Glow blue after a crash.]
Conducir [adelante v] al [choque v]
para siempre
si <¿La unidad está lista?> entonces
resplandor [azul v]
demás
resplandor [verde v]

drive heading#

The drive heading block returns the drivetrain’s heading angle as a decimal number, in the range 0 to 359.99 degrees.

(rumbo de la unidad en grados)

Parameters

Description

This block has no parameters.

Example

cuando empezó
[Display the heading after turning.]
girar [derecha v] por (450) grado
imprimir (rumbo de la unidad en grados) ▶

Sound#

play sound#

The play sound block plays one of the robot’s built-in sounds.

reproducir sonido [bocinazo v]

Parameters

Description

sound

One of the built-in sounds shown below.

Sound Name

Play Sound

honk

doorbell

crash

random

Plays a random sound from the 3 sounds above.

Example

when started, play sound act happy.#
cuando empezó :: hat events
[Play the doorbell sound.]
reproducir sonido [timbre de la puerta v]

LED#

glow#

The glow block sets the color of the LED light.

resplandor [verde v]

Parameters

Description

color

The color to set the LED to:

  • green
  • blue
  • purple
  • off

Example

cuando empezó :: hat events
[Blink the LED light forever.]
para siempre
resplandor [verde v]
esperar [0.5] segundos
resplandor [apagado v]
esperar [0.5] segundos

Actions#

act#

The act block is used to act sad, happy, or crazy by having the 123 Robot perform a sequence of drive, turn, and sound behaviors.

acto [triste v]

Parameters

Description

emotion

The emotion to act out.

  • sad - Drive in reverse, turn left, then right, play an ‘uh oh’ sound, and then will drive forward to act sad.
  • happy - Turn right 360 degrees and play a laughing sound to act happy.
  • crazy - Turn left in a circle, and then turn right in a circle, all while playing a ‘loopy’ sound to act crazy.
cuando empezó :: hat events
[Act out a happy behavior.]
acto [feliz v]

Sensing#

The virtual 123 Robot also has access to the standard Brain and Drivetrain Sensing blocks.

Gyro#

detected crash?#

The detected crash? block returns a Boolean indicating if the robot has come in contact with a wall or other object.

  • True - A crash was detected.

  • False - A crash was not detected.

<¿Se detectó un accidente?>

Parameters

Description

This block has no parameters.

Example

cuando empezó
[Back up after a crash.]
unidad [adelante v]
esperar hasta <¿Se detectó un accidente?>
conducir [atrás v] por (200) [mm v]

Eye#

eye found an object?#

The eye found an object? block returns a Boolean indicating whether or not the Eye Sensor detects an object within range.

  • True - The sensor has detected an object.

  • False - The sensor has not detected an object.

<¿El ojo encontró un objeto?>

Parameters

Description

This block has no parameters.

Example

cuando empezó
[Stop driving after detecting an object.]
establecer luz de ojo [encendido v]
unidad [adelante v]
esperar (0.1) segundos
esperar hasta <¿El ojo encontró un objeto?>
deja de conducir

eye detects color?#

The eye detects color? block returns a Boolean indicating whether the Eye Sensor detects a specified color, based on the detected hue value.

  • True - The sensor detects the specified color.

  • False - The sensor does not detect the specified color.

<¿El ojo detecta [rojo v]?>

Parameters

Description

color

The color to detect:

  • red - A detected hue value between 340°-20°.
  • green - A detected hue value between 80°-145°.
  • blue - A detected hue value between 160°-250°.

Example

cuando empezó
[Stop driving after detecting a green object.]
establecer luz de ojo [encendido v]
unidad [adelante v]
esperar (0.1) segundos
esperar hasta <¿El ojo detecta [verde v]?>
deja de conducir

eye hue#

The eye hue block returns the hue value detected by the Eye Sensor in degrees from 0 to 359.

A circular color wheel displaying a full spectrum of hues labeled with degree values around the perimeter, increasing in 30-degree increments from 0° at the top to 360°.

(tono de ojos en grados)

Parameters

Description

This block has no parameters.

Example

cuando empezó
[Display if an object is pink.]
para siempre
borrar todas las filas
si <[290] [math_less_than v] (tono de ojos en grados) [math_less_than v] [350]> entonces
imprimir [Pink!] ▶
esperar (0.1) segundos
demás
imprimir [Not pink!] ▶
esperar (0.1) segundos

eye bright object?#

The eye bright object? block returns a Boolean indicating whether or not a detected object has a brightness value greater than 70%.

  • True - The detected object has a brightness value over 70%.

  • False - The detected object has a brightness value less than or equal to 70%.

<¿ojo objeto brillante?>

Parameters

Description

This block has no parameters.

Example

cuando empezó
[Display whether a detected object is bright.]
Establezca la potencia de la luz ocular al (100)%
unidad [adelante v]
esperar hasta <¿El ojo encontró un objeto?>
esperar (0.1) segundos
si <¿ojo objeto brillante?> entonces
imprimir [Bright object!] ▶
demás
imprimir [Object not bright.] ▶

eye brightness#

The eye brightness block returns the brightness detected by the Eye Sensor from 0% to 100%.

(brillo ocular en %)

Parameters

Description

This block has no parameters.

Example

cuando empezó
[Display whether a detected object is bright.]
Establezca la potencia de la luz ocular al (100)%
unidad [adelante v]
esperar hasta <¿El ojo encontró un objeto?>
esperar (0.1) segundos
si <(brillo ocular en %) [math_less_than v] [70]> entonces
imprimir [Object not bright.] ▶
demás
imprimir [Bright object!] ▶