Skip to main content

Sensor de líneas

Probando la detección de líneas.
import cyberpi,mbuild

cyberpi.display.show_label("RGB PROBE STATE\nL2:\nL1:\nR1:\nR2:\n", 16, 0, 0, index = 0)

while True:
    l2_line_state = mbuild.quad_rgb_sensor.is_line("L2",1)
    l1_line_state = mbuild.quad_rgb_sensor.is_line("L1",1)
    r1_line_state = mbuild.quad_rgb_sensor.is_line("R1",1)
    r2_line_state = mbuild.quad_rgb_sensor.is_line("R2",1)

    cyberpi.display.show_label(l2_line_state, 16, 30, 18, index = 1)
    cyberpi.display.show_label(l1_line_state, 16, 30, 36, index = 2)
    cyberpi.display.show_label(r1_line_state, 16, 30, 54, index = 3)
    cyberpi.display.show_label(r2_line_state, 16, 30, 72, index = 4)

Extraído de https://github.com/PerfecXX/Python-mBot2/blob/main/README.md licencia MIT
Como puedes ver va detectando las líneas en los 4 sensores que tiene :

Más probatinas...

En https://github.com/PerfecXX/Python-mBot2/tree/main/example/mbuild/02-Quad%20RGB%20Sensor puedes descargarte más scripts que visualizan como el sensor puede detectar el color y el brillo. Nosotros aquí sólo te hemos enseñado el último el de detectar la línea.

2025-04-30 08_32_43-Python-mBot2_example_mbuild_02-Quad RGB Sensor at main · PerfecXX_Python-mBot2 ·.png