How can you sense colors with our Lego sensors? That's for you to figure out. Collect Lego blocks with different colors and experiment what kind of readings you get with both the brightness and the IR sensors. When experimenting make sure you setup a controlled environment both with respect to the location of sensors and the pieces you're examining. When working with the brightness sensors you should make sure you have a consistent illumination.
To help with the illumination (and possibly provide you with additional information) we have available some LEDs that can be plugged into the motor ports and are bi-color (red and green) - use 'thisway' and 'thatway' to get the two different colors. Experiment with these LEDs and see what impact they have on the sensor readings. Again, make sure you setup a nice controlled environement. We do also have some other LEDs that you can experiment if you have other ideas. Come talk to us...
Using 2 or 3 different sensors, how many colors can you reliably distinguish? Write a program that continuously outputs the color of the object. (Be sure that the object whose colors you are sensing are always in the same position, etc.)
red:3 yellow:1 blue:5 total:9In addition, play a different note depending on the color. The program should stop when 10 pieces have been counted. There are a few ways to make this happen, but one is to use concurrency to create a process that does most of the work and increments a counter each time it sees a piece. Then, use a waituntil to check the value of that counter in your main procedure. When it gets to 10, you can call stoprules to kill the process and finish your main procedure.
Your program should be able to distinguish at least 3 different colors.
Note: You that besides the above-mentioned use to get it to count 10 properly, you should probably not use any of the concurrency commands for this assignment. They are likely not necessary here since no two things happen in parallel.