Color and Distance Sensor question #1974
-
Hello, so I'm trying to copy a program I made over onto pybricks and a I'm wondering how to set up a Color and Distance sensor to be used both for sensing colors and running IR programs. On the Powered up app you can do that by swapping what mode the sensor is in with modes 7 and 8, however I keep running into Invalid argument errors whenever I try to use the setup for that. I've tried a few different methods to try to get this error to go away and nothing has seamed to work, and I've been looking for people with this same issue and I'm not finding anything. The reason I'm trying to do it this way is because this is eventually going to become a GBC module, and we already have a bunch of 9-volt/power function's system things and so this would seriously simplify a lot of electronics, thank you guys for your time! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
Hello, You can simply use the distance and the color from the sensor: Output:
Bert |
Beta Was this translation helpful? Give feedback.
-
You've run into a bit of a subtle bug, thanks for reporting! The power function motor is expecting Color.RED or Color.BLUE for the port choice, but both of those are overridden in your program and the motor class doesn't know what to do with your custom values. As a workaround, try renaming your custom colors to This is not related to mode switching. That all happens automatically. |
Beta Was this translation helpful? Give feedback.
-
That seamed to work! thank you! i'll let everyone know if any other issues arise |
Beta Was this translation helpful? Give feedback.
Rename of the custom colors (of course) helps.
Also on the other channels.
A simple program: