I was wondering if there was a way to get color sensors to sense a color and then activate a motor during driver control. IF there is, how would I do this?
I haven’t had a group try this yet…
There are two problems here… One is getting the color, two is setting the motor.
The second part is the easiest, as long as you have a dedicated motor for this. The command setmotortarget will move the motor to a different position based on where it was when the program started. However, if anything else tries to move the motor before it finishes I don’t think it will work properly.
So, let’s say that RED is at 0, GREEN is at 90 and BLUE is at 180. First, make sure the motor is in the zero position (RED) when the program starts.
When the robot detects RED
setmotortarget(motor8,0,50);
When the robot detects GREEN
setmotortarget(motor8,90,50);
When the robot detects BLUE
setmotortarget(motor8,180,50);
As far as reliably getting the color, I’m not sure. There are a few different modes on the sensor that can be tried, but I haven’t had to need to experiment with it yet. Let us know how it goes!
Sankey