ADM Activity 2.1.3

Sorting by Color

Use sensor input or programmed logic to identify and sort objects based on color or another visible property.

Lesson Overview

You will explore how an automated system can identify and sort objects using sensor input. This example uses the optical sensor hue value to decide where the robotic arm should place the object.

Notes

  • This lesson introduces color-based sorting using an optical sensor.
  • The robot picks up one object, moves it to the sensing location, and turns on the optical sensor light.
  • The hue value is used to decide whether the object should go to one bin or another.
  • The else branch provides a fail-safe response if the object does not match the expected color range.
  • Final submitted code must include comments explaining pickup, sensing, decision logic, placement, and fail-safe behavior.
What You Will Submit

What You Submit

  • Engineering notebook entry for Activity 2.1.3
  • Code or pseudocode with meaningful comments
  • Explanation of how the optical sensor is used to sort by color
  • Description of each sorting location or bin
  • Testing notes showing sensor readings, sorting accuracy, and revisions
  • Photo, screenshot, or video evidence of the sorting behavior
  • Short reflection explaining how sensor input improves automation
Code example

2.1.3: Sorting by Color

Review the code, copy it when needed, and add comments before submitting your final version.

VEXcode Python Example
Code examples may be incomplete or missing comments. Comments are required for code submissions.
arm10.move_to(180, 100, 100)

arm10.set_end_effector_type(Arm.MAGNET)
arm10.move_to(100, 200, 20)
arm10.set_end_effector_magnet(True)
arm10.move_to(100, 200, 75)
arm10.move_to(45, 175, 50)

optical_5.set_light(LedStateType.ON)
optical_5.set_light_power(50, PERCENT)
wait(1, SECONDS)

if optical_5.hue() > 50:
    arm10.move_to(175, 0, 100)
    arm10.move_to(175, 0, 30)
    arm10.set_end_effector_magnet(False)
elif optical_5.hue() < 50:
    arm10.move_to(175, 150, 100)
    arm10.move_to(175, 150, 30)
    arm10.set_end_effector_magnet(False)
else:
  arm10.set_control_stop(True)
  signal_tower_6.set_color(SignalTower.BLUE, SignalTower.BLINK)