Understanding Sequences#

Understanding Sequences

This tutorial covers sequencing in VEXcode GO. By the end, you’ll understand why the order of your blocks matters.

A sequence isn’t about which blocks you use — it’s about the order they run in. The blocks in a stack run one at a time, starting with the block at the top and moving down. If the blocks within the sequence are in the wrong order, your robot may not behave the way you want it to.

For example, this project drives the robot forward, then turns it to the right.

Drive, then turn.#
    when started :: hat events
        drive [forward v] for (200) [mm v] ▶
        turn [right v] for (90) degrees ▶

These are the same two blocks, but with their sequence swapped. Now the robot turns first, then drives forward in its new direction — ending up in a different place than before.

Turn, then drive.#
    when started :: hat events
        turn [right v] for (90) degrees ▶
        drive [forward v] for (200) [mm v] ▶

Sequence also matters for blocks that set up the ones after them. If you place a set drive velocity block after your drive blocks, it won’t seem to do anything as those movements already happened before the robot’s velocity was changed.

The set drive velocity block placed too late to have any effect.#
    when started :: hat events
        drive [forward v] for (200) [mm v] ▶
        turn [right v] for (90) degrees ▶
        set drive velocity to (50) %

To actually slow the robot down, the set drive velocity block needs to come before the movements it affects.

The set drive velocity block placed before the movements it affects.#
    when started :: hat events
        set drive velocity to (50) %
        drive [forward v] for (200) [mm v] ▶
        turn [right v] for (90) degrees ▶