Hi, I am new to using sensors so i looked an old post on the forum to get some help and it helped me slightly. I am planning on using an optical sensor to sense the colour of the roller and spin a motor until it is the other colour.
I have a few questions.
First, what do i swap blueball for in this line of code
(Optical.color()) this should return the color of what its looking at and then you can compare that to a range of acceptable values for the red and blue sides to know which side you are looking at, and spin the roller accordingly.
Hue is a good way to detect, being more precise, but the sensor already comes with color presets, as seen in Jpearman’s post here. you can just use Optical1.color() == vex::blue or a different color like Optical1.color() == vex::red. Hope this helps!
I had a similar issue in my code and this is the problem. You are telling the motor to stop spinning if no bumpers are pressed regardless of what color the optical sees. This causes the motor to constantly stop even if the optical sensor sees the right color.
Not connected to why it isn’t spinning but you should maybe remove the waitUntil unless you’re fine with not having any control over your robot until the roller is the correct color. Does it spin when you place it in front of the rollers? Does it spin when you use the bumpers?