Control#

Introduction#

The orange Control cards control the flow of the project and allow the 123 Robot to make decisions. 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.

Below is a list of available cards:

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

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

  • 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 right button – Checks if the right button is pressed on the robot.

  • if left button – Checks if the left button is pressed on the robot.

  • if move button – Checks if the move button is pressed on the robot.

  • if sound button – Checks if the sound button is pressed on the robot.

  • if crash – Checks if the robot detects a crash.

  • 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.

if object#

The if object card uses the Eye Sensor to check if an object is detected directly in front of the 123 Robot. 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, honk. If not, drive forward 1 step.

A red Coder Card that reads when start 123.

An orange Coder Card that reads if object.

A pink Coder Card that reads play honk.

An orange Coder Card that reads else.

A blue Coder Card that reads drive 1.

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 the 123 Robot.

An orange Coder Card that reads if no object.

Example

If nothing is in front of the robot, drive forward 2 steps.

A red Coder Card that reads when start 123.

An orange Coder Card that reads if no object.

A blue Coder Card that reads drive 2.

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 123 Robot’s Eye Sensor detects colors, see Using the Classroom App to Troubleshoot your 123 Robot.

An orange Coder Card that reads if red.

Example

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

A red Coder Card that reads when start 123.

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.

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 123 Robot’s Eye Sensor detects colors, see Using the Classroom App to Troubleshoot your 123 Robot.

An orange Coder Card that reads if green.

Example

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

A red Coder Card that reads when start 123.

A blue Coder Card that reads drive until object.

An orange Coder Card that reads if green.

A purple Coder Card that reads glow 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 123 Robot’s Eye Sensor detects colors, see Using the Classroom App to Troubleshoot your 123 Robot.

An orange Coder Card that reads if blue.

Example

Drive up to an object. If the object is blue, act happy.

A red Coder Card that reads when start 123.

A blue Coder Card that reads drive until object.

An orange Coder Card that reads if blue.

A green Coder Card that reads act happy.

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. The object in front of the Eye Sensor needs to reflect at least 70% of the light to be bright.

An orange Coder Card that reads if bright.

Example

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

A red Coder Card that reads when start 123.

An orange Coder Card that reads if bright.

A purple Coder Card that reads glow green.

An orange Coder Card that reads else.

A purple Coder Card that reads glow purple.

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. If the object in front of the Eye Sensor reflects less than 70% of the light, it is dark.

An orange Coder Card that reads if dark.

Example

If the robot detects something dark, glow blue.

A red Coder Card that reads when start 123.

An orange Coder Card that reads if dark.

A purple Coder Card that reads glow blue.

An orange Coder Card that reads end if.

if right button#

The if right button card checks if the right button is pressed on the 123 Robot.

An orange Coder Card that reads if right button.

Example

Keep checking the right button, and turn right each time it is pressed.

A red Coder Card that reads when start 123.

An orange Coder Card that reads if right button.

A blue Coder Card that reads turn right.

An orange Coder Card that reads end if.

A red Coder Card that reads go to start.

if left button#

The if left button card checks if the left button is pressed on the 123 Robot.

An orange Coder Card that reads if left button.

Example

Keep checking the left button, and turn left each time it is pressed.

A red Coder Card that reads when start 123.

An orange Coder Card that reads if left button.

A blue Coder Card that reads turn left.

An orange Coder Card that reads end if.

A red Coder Card that reads go to start.

if move button#

The if move button card checks if the move button is pressed on the 123 Robot.

An orange Coder Card that reads if move button.

Example

Keep checking the move button, and drive forward 1 step each time it is pressed.

A red Coder Card that reads when start 123.

An orange Coder Card that reads if move button.

A blue Coder Card that reads drive 1.

An orange Coder Card that reads end if.

A red Coder Card that reads go to start.

if sound button#

The if sound button card checks if the sound button is pressed on the 123 Robot.

An orange Coder Card that reads if sound button.

Example

Keep checking the sound button, and play a random sound each time it is pressed.

A red Coder Card that reads when start 123.

An orange Coder Card that reads if sound button.

A pink Coder Card that reads play random.

An orange Coder Card that reads end if.

A red Coder Card that reads go to start.

if crash#

The if crash card checks if the 123 Robot detects a crash.

An orange Coder Card that reads if crash.

Example

Drive forward 1 step. If the robot ran into an object, play the crash sound.

A red Coder Card that reads when start 123.

A blue Coder Card that reads drive 1.

An orange Coder Card that reads if crash.

A pink Coder Card that reads play crash.

An orange Coder Card that reads end if.

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. If not, turn right.

A red Coder Card that reads when start 123.

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.

An orange Coder Card that reads else.

A blue Coder Card that reads turn right.

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 to face away from it. Then, drive forward 1 step either way.

A red Coder Card that reads when start 123.

An orange Coder Card that reads if object.

A blue Coder Card that reads turn right.

An orange Coder Card that reads end if.

A blue Coder Card that reads drive 1.