Lesson: Exercise: Using a Color Sensor

Overview: 
Explore using the Color Sensor device to gather information about the robot's environment.
Objectives: 

Understand how to use the Color Sensor to gather information about the robot's environment.

Content: 

Modern Robotics has a color sensor designed for use with the Tetrix control system. This sensor can read the color of a surface when the surface is within a few centimeters of the sensor. The FTC SDK has a sample program you can use to experiment with the color sensor. In AS, open the path FtcRobotController/java/[first package]/external.samples/SensorMRColor. You can enable this program and work with it but any changes you make will be overwritten at the next update of the SDK. You can copy the class to the teamcode area so any changes you make will be retained.

Here is a detailed discussion of the color sensor on the Modern Robotics website. There is a link on the page to programming information. This is recommended viewing.

This example shows an interesting technique. It gains access to the user interface elements of the FtcRobotController app and uses that access to change the background color of the controller app to match the color detected by the sensor. How this is done and the many other possibilities this opens are beyond the scope of this lesson, but the ability to access and use features of the controller phone is something to be aware of.

 

Navigation: