Control#
Introducción#
The Control blocks in VEXcode AIM manage the flow of a project by handling loops, conditions, and delaying blocks from running.
A loop is when a computer repeats the same step or group of steps over and over until it is told to stop. A condition is a rule the computer checks to decide what to do next. For example, a robot can move forward if a sensor detects an object.
A continuación se muestra una lista de todos los bloques:
wait — Pauses blocks from running for a specific duration.
wait until — Pauses blocks from running until a specified condition is met.
repeat — Repeats a set of blocks a specific number of times.
forever — Repeats a set of blocks indefinitely.
repeat until — Repeats a set of blocks until a condition is met.
while — Repeats a set of blocks while a condition remains true.
if — Runs a set of blocks if a condition is true.
if / else — Ejecuta un conjunto de bloques si una condición es verdadera, de lo contrario ejecuta otro.
if / else if / else — Ejecuta diferentes conjuntos de bloques dependiendo de múltiples condiciones.
break — Sale inmediatamente de un bucle repeat, forever, repeat until o while.
stop project — Ends the project.
esperar#
The wait stack block pauses blocks from running for a specific amount of time before moving to the next block.
wait (1) seconds
Parámetros |
Descripción |
|---|---|
tiempo |
The amount of time to wait, as a positive whole number or decimal in seconds. |
Ejemplo
when started
[Move forward for one second, then stop.]
move [forward v]
wait (1) seconds
stop all movement
Esperar hasta#
The wait until stack block pauses blocks from running until a specified condition is met before moving to the next block.
wait until <>
Parámetros |
Descripción |
|---|---|
condición |
La condición que debe cumplirse antes de pasar al siguiente bloque. |
Ejemplo
when started
[Move forward until screen pressed, then stop.]
move [forward v]
wait until <screen pressed?>
stop all movement
repetir#
The repeat C block runs the blocks inside it a set number of times.
repeat [10]
fin
Parámetros |
Descripción |
|---|---|
veces |
Un número entero que establece cuántas veces se ejecuta el bloque repetir. |
Ejemplo
when started
[Move in a square path.]
repeat [4]
move [forward v] for [50] [mm v] ▶
turn [right v] for [90] degrees ▶
fin
para siempre#
The forever C block keeps running the blocks inside it again and again without stopping.
forever
fin
Parámetros |
Descripción |
|---|---|
Este bloque no tiene parámetros. |
Ejemplo
when started
[Move in a square path forever.]
forever
move [forward v] for [50] [mm v] ▶
turn [right v] for [90] degrees ▶
fin
repetir hasta#
The repeat until C block runs the blocks inside it repeatedly while the specified condition is not met.
repeat until <>
fin
Parámetros |
Descripción |
|---|---|
condición |
An expression or variable that is checked before each loop. If it is False, the blocks continue repeating. If it is True, the loop will stop. |
Ejemplo
when started
[Repeat until the screen is pressed before turning off the LEDs.]
repeat until <screen pressed?>
set [lightall v] LED color to [red v]
fin
set [lightall v] LED color to [off v]
mientras#
The while C block runs the blocks inside repeatedly while the specified condition is met.
while <>
fin
Parámetros |
Descripción |
|---|---|
condición |
An expression or variable that is checked before each loop. If it is True, the blocks continue repeating. If it is False, the loop will stop. |
Ejemplo
when started
[Keep the LEDs green while the robot is moving.]
move [forward v] for [200] [mm v] ◀ and don't wait
while <move active?>
set [lightall v] LED color to [green v]
fin
set [lightall v] LED color to [off v]
si#
The if C block runs the blocks inside if the condition is True.
if <> then
fin
Parámetros |
Descripción |
|---|---|
condición |
An expression or variable that is checked when the statement runs. If it is True, the blocks inside the if block will run. If it is False, the blocks are skipped over. |
Ejemplo
when started
[Kick when the screen is pressed.]
forever
if <screen pressed?> then
kick object [medium v]
fin
fin
si/de lo contrario#
The if / else C block determines which set of blocks runs based on whether the condition is True or False.
if <> then
else
fin
Parámetros |
Descripción |
|---|---|
condición |
An expression or variable that is checked when the statement runs. If it is True, the blocks inside the if block will run. If it is False, it will runs the blocks inside the else block. |
Ejemplo
when started
[Show one emoji when the screen is touched and a different one when it's not.]
forever
if <screen pressed?> then
show [emoji_excited v] looking [forward v]
else
show [emoji_bored v] looking [forward v]
fin
fin
si/si no si/si no#
The if / else if / else expandable C block selects which set of blocks runs based on conditions:
if runs its block of code if the condition evaluates as True.
else if checks additional conditions only if all previous conditions evaluated as False. Multiple else if statements can be used.
else runs its block of code only if none of the previous conditions evaluated as True.
if <> then
else if <> then
else
fin
Parámetros |
Descripción |
|---|---|
condición |
An expression or variable that is checked when the statement runs. The first condition that is True runs that set of blocks. If all conditions evaluate as False, the blocks inside the else block will run. |
Ejemplo
when Controller axis [1 v] is changed
[Move the robot forward or reverse based on the position of the joystick.]
if <(controller axis [1 v] position) [math_greater_than v] [0]> then
move [forward v]
else if <(controller axis [1 v] position) [math_less_than v] [0]> then
move [reverse v]
else
stop all movement
fin
romper#
The break stack block exits a loop immediately. This block can be used inside repeat, repeat until, while, and forever blocks. Break is useful when a loop needs to stop early based on something that happens during the project, like a button being pressed or a sensor detecting an object.
break
Parámetros |
Descripción |
|---|---|
Este bloque no tiene parámetros. |
Ejemplo
when started
[Flash LEDs until the screen is pressed.]
forever
set [lightall v] LED color to [red v]
wait [0.5] seconds
set [lightall v] LED color to [green v]
wait [0.5] seconds
if <screen pressed?> then
break
fin
fin
detener el proyecto#
The stop project stack block ends a running project.
stop project
Parámetros |
Descripción |
|---|---|
Este bloque no tiene parámetros. |
Ejemplo
when started
[Stop the project once the screen is pressed.]
forever
set [lightall v] LED color to [red v]
wait [0.5] seconds
set [lightall v] LED color to [green v]
wait [0.5] seconds
if <screen pressed?> then
stop project
fin
fin