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/pup/sensor_color_distance/color_print.py
../../../examples/pup/sensor_color_distance/wait_for_color.py
../../../examples/pup/sensor_color_distance/distance_blink.py
../../../examples/pup/sensor_color_distance/distance_blink.py
../../../examples/pup/sensor_color_distance/hsv.py
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