More Code Blocks for Powered-Up/Mindstorms Color Sensor? #1720
Replies: 2 comments 1 reply
-
You can do that as follows: However....
This isn't due to the light of the sensor. The sensor can tell the color of an object by emitting some light and measuring what comes back. So the sensor light will always turn back on when scanning the color of an object. Instead, you'll want to calibrate the sensor. You can tell it what the colors in your application look like, so the sensor will be able to differentiate them. Here is a tutorial. This shows an example for color markers on train tracks, but it works just the same for candy in a vending machine using the Mindstorms Color Sensor. |
Beta Was this translation helpful? Give feedback.
-
This is also covered in the tutorial :) In that case, the train tracks and the floor are the background. In your case, it could be whatever it sees behind the candy pieces you're scanning.
This is already happening. It will round the measurement to the nearest matching color that you've set up. Depending on the number of colors you set up, it will work far beyond ± 15 degrees. This is what makes it so powerful compared to the LEGO method. If you specify that your application has only red, blue, and black, for example, then "yellow" and "orange" will automatically rounded to red, rather than reporting incorrect values as you would get with the stock firmware. |
Beta Was this translation helpful? Give feedback.
-
Are you interested in having more Pybricks code blocks for the Powered-Up/Mindstorms Robot Inventor Color Sensor?
This would be useful for creating more complex robot behaviors, especially for tasks like line following or color sorting where precise color detection is crucial.
One specific functionality I'd love to see is a block that allows us to turn off the built-in light on the color sensor while it detects colors in a loop. This is particularly important for projects like mine, where the sensor struggles to differentiate between black and white due to the brightness of the built-in light.
If you'd like to see an example of how these blocks could be used in a Lego Mindstorms vending machine project, check out the LCR Brick Tech Channel. Consider subscribing for a notification when the vending machine video is released!
0 votes ·
Beta Was this translation helpful? Give feedback.
All reactions