Until now, I’ve never really used my color sensor, so I decided to give it a try.
I wanted to see whether it is possible to sort M&M’s based on their color.
The construction consists of 3 main parts:
- A slow caterpillar track where you can add all your M&M’s
- A faster caterpillar track where the color is checked
- Four buckets for each color
Slow caterpillar track
This is a larger area so that it can hold a lot of M&M’s at once. The caterpillar track moves slowly so that the next part only gets one M&M at a time.
Both caterpillar tracks run at a different speed, so that distance between M&M’s is increased. The color is checked on the second caterpillar track.
The buckets rotate so that they can catch the M&M’s just in time.
This first part of coding takes care of the startup of the machine, and sets both caterpillar tracks in motion.
This next part handles the color detection, and gives instructions to the motor that controls the buckets.