- :-

Topics Covered

  • Move Until Color Behavior
  • Lesson Links

    Check Your Understanding:
    1. 1. What does this program do when run?
    2. Move forward when the Color Sensor sees a red object
      Move forward until the Color Sensor sees a red object
      Move forward until the Color Sensor sees a green object
      Move forward as long as nothing is in the robot's way
    3. 2. What would happen is the red cube was replaced with a green one and the same program was run?
    4. The robot would still stop when it came to the green cube.
      The robot would keep going since the condition for the robot stopping was the color sensor detecting the color red.
      The robot would not move since it is waiting for the color sensor to detect the color red before it starts moving
      The robot would begin moving backwards because that is what it was programmed to do when it saw the color green
    Try It!
    Try it! 1

    Color Sensor Values

    The VEX IQ Color sensor is capable of several different modes:
    Color Name, Grayscale, Hue, and Proximity. The readings from the color sensor are extremely sensitive to “ambient” light in the robots environment.

    Download and run this program to output the values from the sensor in each of the modes to the VEX IQ Screen. Try it!

    Real Robot users

    • After downloading the program, move the robot by hand to differently colored objects and surfaces, keeping the sensor 2-3 centimeters from the object.
    • Notice how different hue values correspond to different color names, and how changes in the ambient light of your environment affect the sensor.

    Virtual Robot users

    • After downloading the program, in ROBOTC go to Robot > Debugger Window > VEX IQ Remote Screen to view the values from your computer screen.
    • Use the WASD Keyboard keys to maneuver your robot around the virtual table, pointing the color sensor at the differently colored objects.
    • Notice how different hue values correspond to different color names.
    What happens?
    As the color sensor is pointed at differently colored objects, the values on the screen update. Certain hue values correspond with certain color names. If the lighting in the environment varies, so do the sensor readings.
    How does it work?

    How does it work?

    Color Sensor


    You can use the following color names in your programs for the Color Sensor:



    colorNone colorRedViolet colorRed colorDarkOrange colorOrange
    colorDarkYellow colorYellow colorLimeGreen colorGreen colorBlueGreen
    colorBlue colorDarkBlue colorViolet