Transmisión#
Introducción#
The drivetrain includes wheels and motors that control how the robot drives and turns. Drivetrains can be found in builds like the Code Base 2.0, Super Car, or a custom robot.
Drivetrains use the Inertial Sensor in the Brain to detect crashes and help the robot move and turn precisely. At the start of each project, the drivetrain calibrates the Inertial Sensor automatically. Keep the robot still for about 2 seconds during calibration, so the robot can move and turn correctly.
There are many ways to code the drivetrain. Below is a list of all Drivetrain blocks:
Acciones: Mover y girar el robot.
drive — Moves the robot forward or reverse forever.
drive for — Moves the robot forward or reverse for a specific distance.
drive until — Moves the robot forward or reverse until the Eye Sensor detects an object or the robot detects a crash.
turn — Turns the robot left or right forever.
turn for — Turns the robot left or right for a specific number of degrees.
turn to heading — Turns the robot to face a specific heading from -359 to 359 degrees. The robot will turn the shortest direction to reach the target heading.
turn to rotation — Turns the robot to a specific rotation.
stop driving — Stops the robot’s movement.
Ajustes: Ajuste la configuración de la transmisión.
set drive velocity — Tells the robot how fast to drive.
set turn velocity — Tells the robot how fast to turn.
set drive stopping — Tells how the robot will stop moving: by braking, coasting, or holding.
set drive timeout — Sets how many seconds the robot will try to finish a movement.
set drive heading — Changes the robot’s current heading to a new heading.
set drive rotation — Changes the robot’s current rotation to a new rotation.
Valores: comprobar el estado del movimiento.
drive is done — Reports whether the robot is finished moving.
drive heading — Reports the robot’s current heading from 0 to 359 degrees.
drive rotation — Reports the robot’s current rotation.
drive velocity — Reports how fast the robot is driving, as a percentage from -100% to 100%.
Comportamiento#
conducir#
The drive stack block moves the robot forward or reverse forever. The robot will continue to move until it is given another action, like turning or stopping.
unidad [adelante v]
Parámetros |
Descripción |
|---|---|
dirección |
The direction the robot moves: forward or reverse. |
Ejemplo
cuando empezó :: hat events
[Build Used: Code Base 2.0]
[Drive forward then stop.]
unidad [adelante v]
esperar (2) segundos
deja de conducir
conducir para#
The drive for stack block moves the robot forward or reverse for a specific distance. The project will wait until the robot is done moving before the next block in the stack runs.
unidad [adelante v] para [100] [mm v] ▶
Parámetros |
Descripción |
|---|---|
dirección |
The direction the robot moves: forward or reverse. |
distancia |
The distance the robot drives. This can be an integer or a decimal. |
unidad |
The distance unit: mm (millimeters) or inches. |
and don’t wait |
Select the arrow ( ▶ ) to expand the block to say and don’t wait, so the next block in the stack will run right away. |
Ejemplo
cuando empezó :: hat events
[Build Used: Code Base 2.0]
[Drive back and forth.]
unidad [adelante v] para [100] [mm v] ▶
unidad [atrás v] para [4] [pulgadas v] ▶
conducir hasta#
The drive until stack block moves the robot forward or reverse until the Eye Sensor detects an object or the robot detects a crash.
Conducir [adelante v] al [objeto v] ▶
Parámetros |
Descripción |
|---|---|
dirección |
The direction the robot moves: forward or reverse. |
condición |
The condition that stops the robot: object or crash. |
and don’t wait |
Select the arrow ( ▶ ) to expand the block to say and don’t wait, so the next block in the stack will run right away. |
Ejemplo
cuando empezó :: hat events
[Build Used: Code Base 2.0]
[Turn right after a crash.]
Conducir [adelante v] al [choque v] ▶
girar [derecha v] por (90) grado ▶
doblar#
The turn stack block turns the robot left or right forever. The robot will continue to turn until it is given another action, like driving to stopping.
turno [derecha v]
Parámetros |
Descripción |
|---|---|
dirección |
The direction the robot turns: left or right. |
Ejemplo
cuando empezó :: hat events
[Build Used: Code Base 2.0]
[Turn right and left, then stop.]
turno [derecha v]
esperar [2] segundos
turno [izquierda v]
esperar [2] segundos
deja de conducir
girar para#
The turn for stack block turns the robot left or right for a specific number of degrees. The turn is relative to the current position of the robot. The project will wait until the robot is done turning before the next block in the stack runs.
girar [derecha v] por (90) grado ▶
Parámetros |
Descripción |
|---|---|
dirección |
The direction the robot turns: left or right. |
ángulo |
The number of degrees the robot turns. This can be an integer or a decimal. |
and don’t wait |
Select the arrow ( ▶ ) to expand the block to say and don’t wait, so the next block in the stack will run right away. |
Ejemplo
cuando empezó :: hat events
[Build Used: Code Base 2.0]
[Turn right then left.]
girar [derecha v] por (90) grado ▶
girar [izquierda v] por (90) grado ▶
girar al rumbo#
A heading is the direction the robot’s brain is facing, measured in degrees. The turn to heading stack block turns the robot to face a specific heading from -359 to 359 degrees. The robot will turn the shortest direction to reach the target heading.
The starting heading is 0 degrees.

The project will wait until the robot is done turning before the next block in the stack runs.
girar hacia el rumbo [90] grados ▶
Parámetros |
Descripción |
|---|---|
título |
The direction the robot should face as an integer, from -359 to 359 degrees. |
and don’t wait |
Select the arrow ( ▶ ) to expand the block to say and don’t wait, so the next block in the stack will run right away. |
Ejemplo
cuando empezó :: hat events
[Build Used: Code Base 2.0]
[Turn to face the cardinal directions.]
girar hacia el rumbo [90] grados ▶
esperar [1] segundos
girar hacia el rumbo [180] grados ▶
esperar [1] segundos
girar hacia el rumbo [270] grados ▶
esperar [1] segundos
girar hacia el rumbo [0] grados ▶
pasar a rotación#
The turn to rotation stack block turns the robot to a specific rotation.
Rotation is how much the robot has turned, measured in degrees. At the beginning of a project, the rotation value is set to 0 degrees. Rotation can also be set using the set drive rotation block.
Rotation values are absolute. This means the direction of the turn depends on the robot’s current rotation. Turning right increases the rotation, and turning left decreases the rotation.
For example, if the robot starts at 0 degrees and you turn to a rotation of 720 degrees, it will turn right twice. If you then turn to a rotation of 360 degrees, it will turn left once, because 360 is less than 720.

The project will wait until the robot is done turning before the next block in the stack runs.
girar a rotación (90) grados ▶
Parámetros |
Descripción |
|---|---|
rotación |
The rotation value, in degrees, that the robot will turn to. This can be an integer. |
and don’t wait |
Select the arrow ( ▶ ) to expand the block to say and don’t wait, so the next block in the stack will run right away. |
Ejemplo
cuando empezó :: hat events
[Build Used: Code Base 2.0]
[Make one full turn to the right.]
girar a rotación [360] grados ▶
[Make another full turn to the right.]
girar a rotación [720] grados ▶
[Make one full turn to the left, returning to 360 degrees.]
girar a rotación [360] grados ▶
deja de conducir#
The stop driving stack block stops the robot’s movement.
deja de conducir
Parámetros |
Descripción |
|---|---|
Este bloque no tiene parámetros. |
Ejemplo
cuando empezó :: hat events
[Build Used: Code Base 2.0]
[Drive forward then stop.]
unidad [adelante v]
esperar (2) segundos
deja de conducir
Settings#
establecer la velocidad de conducción#
The set drive velocity stack block tells the robot how fast to drive. A higher percentage makes the robot drive faster and a lower percentage makes the robot drive slower.
Every project begins with the robot driving at 50% velocity by default.
Note: A higher velocity makes the robot drive faster, but it may be less precise. A lower velocity makes the robot drive slower, but be more precise.
set drive velocity to [50] %
Parámetros |
Descripción |
|---|---|
velocidad |
The velocity to drive with from 0% to 100%. |
Ejemplo
cuando empezó :: hat events
[Build Used: Code Base 2.0]
[Drive at different velocities.]
unidad [adelante v] para [100] [mm v] ▶
esperar [1] segundos
[Drive slow.]
set drive velocity to [20] %
unidad [adelante v] para [100] [mm v] ▶
esperar [1] segundos
[Drive fast.]
set drive velocity to [100] %
unidad [adelante v] para [100] [mm v] ▶
establecer la velocidad de giro#
The set turn velocity stack block tells the robot how fast to turn. A higher percentage makes the robot turn faster and a lower percentage makes the robot turn slower.
Every project begins with the robot turning at 50% velocity by default.
Note: A higher velocity makes the robot turn faster, but it may be less precise. A lower velocity makes the robot turn slower, but be more precise.
set turn velocity to [50] %
Parámetros |
Descripción |
|---|---|
velocidad |
The velocity to turn with from 0% to 100%. |
Ejemplo
cuando empezó :: hat events
[Build Used: Code Base 2.0]
[Turn at different velocities.]
girar [derecha v] por [180] grado ▶
esperar [1] segundos
[Turn fast.]
set turn velocity to [100] %
girar [derecha v] por [180] grado ▶
Establecer la parada de la unidad#
The set drive stopping stack block sets how the robot will stop moving: by braking, coasting, or holding.
Establecer la detención de la unidad en [freno v]
Parámetros |
Descripción |
|---|---|
comportamiento de detención |
How the robot will stop:
|
If this block is not used, the robot will use brake when stopping.
Ejemplo
cuando empezó :: hat events
[Build Used: Code Base 2.0]
[Drive, then coast to a stop.]
set drive velocity to [100] %
Establecer la detención de la unidad en [libre v]
unidad [adelante v]
esperar [2] segundos
deja de conducir
establecer el tiempo de espera de la unidad#
The set drive timeout stack block sets how many seconds the robot will try to finish a movement. If the robot cannot finish in that time it will stop trying and move on to the next block in the stack. This keeps the robot from getting stuck on a movement.
Establezca el tiempo de espera de la unidad en [1] segundos
Parámetros |
Descripción |
|---|---|
tiempo |
The number of seconds the robot can try to finish a movement. This can be a whole number or a decimal. |
Ejemplo
cuando empezó :: hat events
[Build Used: Code Base 2.0]
[Drive as far as possible for 1 second before turning right.]
Establezca el tiempo de espera de la unidad en [1] segundos
unidad [adelante v] para [25] [pulgadas v] ▶
girar [derecha v] por [90] grado ▶
establecer el rumbo de la unidad#
A heading is the direction the robot’s brain is facing, measured in degrees. The set drive heading stack block changes the robot’s current heading to a new heading value.
For example, if the robot has turned to face right, setting the heading to 0 degrees makes that right-facing position the new 0 degrees. Then the robot can turn to other positions based on that new heading.
establecer el rumbo de la unidad a [0] grados
Parámetros |
Descripción |
|---|---|
título |
The heading value, in degrees, to set for the robot. This can be a whole number from 0 to 359. |
Ejemplo
cuando empezó :: hat events
[Build Used: Code Base 2.0]
[Face the new 0 degree heading.]
establecer el rumbo de la unidad a [90] grados
girar hacia el rumbo [0] grados ▶
establecer la rotación de la unidad#
Rotation is how much the robot has turned, measured in degrees. At the beginning of a project, the rotation value is set to 0 degrees. The set drive rotation stack block changes the robot’s current rotation to a new value.
For example, if the robot has made two full turns to the right, its rotation value will be 720 degrees. Setting the rotation to 0 degrees will reset that rotation from 720 to 0 degrees. Then the robot can turn to rotations based on that new value.
establecer la rotación de la unidad a (0) grados
Parámetros |
Descripción |
|---|---|
rotación |
The rotation value, in degrees, to set for the robot. This can be an integer. |
Ejemplo
cuando empezó :: hat events
[Build Used: Code Base 2.0]
[Spin counterclockwise two times.]
establecer la rotación de la unidad a [720] grados
girar a rotación [0] grados ▶
Valores#
drive is done#
The drive is done Boolean block reports whether the robot is finished moving. This can be used to control the timing of other behaviors based on the robot’s movement.
True — The robot is finished moving.
False — The robot is still moving.
This block works together with the following drivetrain blocks that have the and don’t wait parameter: drive for, drive until, turn for, turn to heading, and turn to rotation.
<¿La unidad está lista?>
Parámetros |
Descripción |
|---|---|
Este bloque no tiene parámetros. |
Ejemplo
cuando empezó :: hat events
[Build Used: Code Base 2.0]
[Turn when the drivetrain is done moving forward.]
unidad [adelante v] para [100] [mm v] ◀ y no esperes
esperar [0.25] segundos
para siempre
si <¿La unidad está lista?> entonces
girar [derecha v] por [180] grado ▶
romper
demás
imprimir [Still moving...] ▶
esperar [0.1] segundos
borrar todas las filas
rumbo de la unidad#
A heading is the direction the robot’s brain is facing, measured in degrees. The drive heading reporter block reports that heading from 0 to 359 degrees.
The robot’s starting heading is 0 degrees.

(rumbo de la unidad en grados)
Parámetros |
Descripción |
|---|---|
Este bloque no tiene parámetros. |
Ejemplo
cuando empezó :: hat events
[Build Used: Code Base 2.0]
[Display the heading while turning.]
girar [derecha v] por [450] grado ◀ y no esperes
para siempre
borrar todas las filas
imprimir (rumbo de la unidad en grados) ▶
esperar [0.1] segundos
rotación de la unidad#
Rotation is how much the robot has turned, measured in degrees. At the beginning of a project, the rotation value is set to 0 degrees. The drive rotation reporter block reports the robot’s current rotation.
Turning right increases the rotation, and turning left decreases the rotation. For example, making two full turns to the right will report a rotation of 720 degrees.

(rotación de la unidad en grados)
Parámetros |
Descripción |
|---|---|
Este bloque no tiene parámetros. |
Ejemplo
cuando empezó :: hat events
[Build Used: Code Base 2.0]
[Display the rotation while turning.]
girar [derecha v] por [450] grado ◀ y no esperes
para siempre
borrar todas las filas
imprimir (rotación de la unidad en grados) ▶
esperar [0.1] segundos
velocidad de accionamiento#
The drive velocity reporter block reports how fast the robot is driving, as a percentage from -100% to 100%.
A positive value means the robot is driving forward. A negative value means the robot is driving in reverse.
(velocidad de accionamiento en %)
Parámetros |
Descripción |
|---|---|
Este bloque no tiene parámetros. |
Ejemplo
cuando empezó :: hat events
[Build Used: Code Base 2.0]
[Display the velocity of the robot before and while moving.]
imprimir [Start: ] ▶
imprimir (velocidad de accionamiento en %) ▶
colocar el cursor en la siguiente fila
unidad [adelante v]
esperar [0.5] segundos
imprimir [Moving: ] ▶
imprimir (velocidad de accionamiento en %) ▶
deja de conducir