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.
Example
If an object is in front of the robot, turn right 90°. If not, drive forward 15 cm.
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.
Example
If nothing is in front of the robot, drive forward 30 cm.
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.
Example
Drive up to an object. If the object is red, turn left 90°.
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.
Example
Drive up to an object. If the object is green, glow the LED Bumper green.
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.
Example
Drive up to an object. If the object is blue, turn around.
if bright#
The if bright card uses the Eye Sensor to check if bright ambient light or a bright object is detected.
Example
If the robot detects something bright, glow green. If not, glow red.
if dark#
The if dark card uses the Eye Sensor to check if no ambient light or a dark object is detected.
Example
If the robot detects something dark, glow red.
if pressed#
The if pressed card checks if the LED Bumper is pressed.
Example
Keep checking the LED Bumper. Glow green while it is pressed, and red while it is not.
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.
Example
Drive up to an object. If the object is red, turn left 90°. If not, turn right 90°.
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.
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.
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.
Example
Drive forward 15 cm and back again, 2 times.
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.
Example
Drive in a square by driving forward 30 cm and turning right 90°, 4 times.
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.
Example
Turn right 45° 8 times to spin all the way around.
end repeat#
The end repeat card ends the sequence of cards that a repeat card repeats.
Example
Turn right 90° 2 times, then drive forward 15 cm.