Control#

Introduction#

The orange Control cards control the flow of the project and allow the robot to make decisions or repeat cards. An if card checks a condition, and the cards under it run if the condition is met. The else card runs the cards under it if the condition is not met, and the end if card ends a sequence of if and else cards. A repeat card runs the cards between it and the end repeat card a set number of times.

An if sequence can go inside a repeat sequence, and a repeat sequence can go inside an if sequence. An if card can’t go inside another if sequence, and a repeat card can’t go inside another repeat sequence.

Below is a list of available cards:

  • if object – Checks if an object is detected directly in front of the Eye Sensor.

  • if no object – Checks if an object is not detected directly in front of the Eye Sensor.

  • if red – Checks if the color red is detected.

  • if green – Checks if the color green is detected.

  • if blue – Checks if the color blue is detected.

  • if bright – Checks if bright ambient light or a bright object is detected.

  • if dark – Checks if no ambient light or a dark object is detected.

  • if pressed – Checks if the LED Bumper is pressed.

  • else – Runs the cards under it if the condition of the if card is not met.

  • end if – Ends a sequence of if and else cards so the project can continue.

  • repeat 2 times – Repeats the cards up to the end repeat card 2 times.

  • repeat 4 times – Repeats the cards up to the end repeat card 4 times.

  • repeat 8 times – Repeats the cards up to the end repeat card 8 times.

  • end repeat – Ends the sequence of cards repeated by a repeat card.

if object#

The if object card uses the Eye Sensor to check if an object is detected directly in front of it. An object needs to be approximately 18 mm from the Eye Sensor to be detected.

An orange Coder card that reads if object.

Example

If an object is in front of the robot, turn right 90°. If not, drive forward 15 cm.

A red Coder card that reads when start GO.

An orange Coder card that reads if object.

A blue Coder card that reads turn right 90°.

An orange Coder card that reads else.

A blue Coder card that reads drive 15 cm.

An orange Coder card that reads end if.

if no object#

The if no object card uses the Eye Sensor to check if an object is not detected directly in front of it.

An orange Coder card that reads if no object.

Example

If nothing is in front of the robot, drive forward 30 cm.

A red Coder card that reads when start GO.

An orange Coder card that reads if no object.

A blue Coder card that reads drive 30 cm.

An orange Coder card that reads end if.

if red#

The if red card uses the Eye Sensor to check if the color red is detected. Red is a hue from 340° to 20°.

For more detailed information about how the VEX GO Eye Sensor detects colors, see Using the VEX Classroom App to Troubleshoot Your VEX GO Robot.

An orange Coder card that reads if red.

Example

Drive up to an object. If the object is red, turn left 90°.

A red Coder card that reads when start GO.

A blue Coder card that reads drive until object.

An orange Coder card that reads if red.

A blue Coder card that reads turn left 90°.

An orange Coder card that reads end if.

if green#

The if green card uses the Eye Sensor to check if the color green is detected. Green is a hue from 80° to 145°.

For more detailed information about how the VEX GO Eye Sensor detects colors, see Using the VEX Classroom App to Troubleshoot Your VEX GO Robot.

An orange Coder card that reads if green.

Example

Drive up to an object. If the object is green, glow the LED Bumper green.

A red Coder card that reads when start GO.

A blue Coder card that reads drive until object.

An orange Coder card that reads if green.

A purple Coder card that reads LED green.

An orange Coder card that reads end if.

if blue#

The if blue card uses the Eye Sensor to check if the color blue is detected. Blue is a hue from 160° to 250°.

For more detailed information about how the VEX GO Eye Sensor detects colors, see Using the VEX Classroom App to Troubleshoot Your VEX GO Robot.

An orange Coder card that reads if blue.

Example

Drive up to an object. If the object is blue, turn around.

A red Coder card that reads when start GO.

A blue Coder card that reads drive until object.

An orange Coder card that reads if blue.

A blue Coder card that reads turn around 180°.

An orange Coder card that reads end if.

if bright#

The if bright card uses the Eye Sensor to check if bright ambient light or a bright object is detected.

An orange Coder card that reads if bright.

Example

If the robot detects something bright, glow green. If not, glow red.

A red Coder card that reads when start GO.

An orange Coder card that reads if bright.

A purple Coder card that reads LED green.

An orange Coder card that reads else.

A purple Coder card that reads LED red.

An orange Coder card that reads end if.

if dark#

The if dark card uses the Eye Sensor to check if no ambient light or a dark object is detected.

An orange Coder card that reads if dark.

Example

If the robot detects something dark, glow red.

A red Coder card that reads when start GO.

An orange Coder card that reads if dark.

A purple Coder card that reads LED red.

An orange Coder card that reads end if.

if pressed#

The if pressed card checks if the LED Bumper is pressed.

An orange Coder card that reads if pressed.

Example

Keep checking the LED Bumper. Glow green while it is pressed, and red while it is not.

A red Coder card that reads when start GO.

An orange Coder card that reads if pressed.

A purple Coder card that reads LED green.

An orange Coder card that reads else.

A purple Coder card that reads LED red.

An orange Coder card that reads end if.

A red Coder card that reads go to start.

else#

The else card is used together with an if card. The else card will run the cards under it if the condition of the if card is not met.

An orange Coder card that reads else.

Example

Drive up to an object. If the object is red, turn left 90°. If not, turn right 90°.

A red Coder card that reads when start GO.

A blue Coder card that reads drive until object.

An orange Coder card that reads if red.

A blue Coder card that reads turn left 90°.

An orange Coder card that reads else.

A blue Coder card that reads turn right 90°.

An orange Coder card that reads end if.

end if#

The end if card ends a sequence of if and else cards. Use it to continue the project after the decision is made. The cards after the end if card run whether or not the condition of the if card was met.

An orange Coder card that reads end if.

Example

If an object is in front of the robot, turn right 90° to face away from it. Then, drive forward 15 cm either way.

A red Coder card that reads when start GO.

An orange Coder card that reads if object.

A blue Coder card that reads turn right 90°.

An orange Coder card that reads end if.

A blue Coder card that reads drive 15 cm.

repeat 2 times#

The repeat 2 times card runs the cards between it and the end repeat card 2 times, then moves on to the card after end repeat.

An orange Coder card that reads repeat 2 times.

Example

Drive forward 15 cm and back again, 2 times.

A red Coder card that reads when start GO.

An orange Coder card that reads repeat 2 times.

A blue Coder card that reads drive 15 cm.

A blue Coder card that reads reverse 15 cm.

An orange Coder card that reads end repeat.

repeat 4 times#

The repeat 4 times card runs the cards between it and the end repeat card 4 times, then moves on to the card after end repeat.

An orange Coder card that reads repeat 4 times.

Example

Drive in a square by driving forward 30 cm and turning right 90°, 4 times.

A red Coder card that reads when start GO.

An orange Coder card that reads repeat 4 times.

A blue Coder card that reads drive 30 cm.

A blue Coder card that reads turn right 90°.

An orange Coder card that reads end repeat.

repeat 8 times#

The repeat 8 times card runs the cards between it and the end repeat card 8 times, then moves on to the card after end repeat.

An orange Coder card that reads repeat 8 times.

Example

Turn right 45° 8 times to spin all the way around.

A red Coder card that reads when start GO.

An orange Coder card that reads repeat 8 times.

A blue Coder card that reads turn right 45°.

An orange Coder card that reads end repeat.

end repeat#

The end repeat card ends the sequence of cards that a repeat card repeats.

An orange Coder card that reads end repeat.

Example

Turn right 90° 2 times, then drive forward 15 cm.

A red Coder card that reads when start GO.

An orange Coder card that reads repeat 2 times.

A blue Coder card that reads turn right 90°.

An orange Coder card that reads end repeat.

A blue Coder card that reads drive 15 cm.