Skip to content

Latest commit

 

History

History
79 lines (51 loc) · 2.27 KB

colordistancesensor.rst

File metadata and controls

79 lines (51 loc) · 2.27 KB

Color and Distance Sensor

pybricks.pupdevices.ColorDistanceSensor

pybricks.pupdevices.ColorDistanceSensor.color

pybricks.pupdevices.ColorDistanceSensor.reflection

pybricks.pupdevices.ColorDistanceSensor.ambient

pybricks.pupdevices.ColorDistanceSensor.distance

pybricks.pupdevices.ColorDistanceSensor.hsv

pybricks.pupdevices.ColorDistanceSensor.detectable_colors

Built-in light

This sensor has a built-in light. You can make it red, green, blue, or turn it off. If you use the sensor to measure something afterwards, the light automatically turns back on at the default color for that sensing method.

pybricks.pupdevices::ColorDistanceSensor.light.on

pybricks.pupdevices::ColorDistanceSensor.light.off

Examples

Measuring color

../../../examples/pup/sensor_color_distance/color_print.py

Waiting for a color

../../../examples/pup/sensor_color_distance/wait_for_color.py

Measuring distance

../../../examples/pup/sensor_color_distance/distance_blink.py

Blinking the built-in light

../../../examples/pup/sensor_color_distance/distance_blink.py

Reading hue, saturation, value

../../../examples/pup/sensor_color_distance/hsv.py

Changing the detectable colors

By default, the sensor is configured to detect red, yellow, green, blue, white, or no color, which suits many applications.

For better results in your application, you can measure your desired colors in advance, and tell the sensor to look only for those colors. Be sure to measure them at the same distance and light conditions as in your final application. Then you'll get very accurate results even for colors that are otherwise hard to detect.

../../../examples/pup/sensor_color_distance/detectable_colors.py