How to code a Optical Sensor

Hello, I am new to coding and my team wants to use an Optical sensor for our intake. I don’t know how to code it and need much help as possible from you guys. I wanted our intake to pick up red discs and when it picks up a blue disc the intake will go the other way. I use Vex Pros c++ so if you could help me code this, it would be greatly appreciated.

Look into this documentation
https://pros.cs.purdue.edu/v5/api/cpp/optical.html#get-rgb

If anyone is using an Optical Sensor, can I see your code for reference. Please!

This code segment uses an optical sensor that detects ranges of colors to sort out rings during driver control. (loop not shown)

1 Like

Also when I try the code, the optical sensor takes in the blue rings and doesn’t do anything thing with red rings.

Isn’t that your intended purpose for the optical sensor?

Yeah, but when it detects the red rings it should outtake and it just stops and does nothing, Thats what I meant.