Color Sensor code for REV Color Sensor V3

I intend to use the REV color sensor to lock the note inside our shooter, so I wanted to clear my doubts here, I wanted to know how its electrical work, and especially the sensor code, I don’t have the slightest idea of How would it work, is there any example code for me to guide myself?

Everything you should need is on the product page here: Color Sensor V3 - REV Robotics

Specifically, the link to the datasheet is a link to the hardware specs for it (power/data pinout, electrical properties, effective range, etc). Also, there are links to the revlib docs, which is the software library for interacting with the color sensor, and some example code to reference.

I checked these links and the example code, but there was one thing that left me in doubt.
Which is about that final private I2C.Port i2cPort = I2C.Port.kOnboard;
Inside the code he said to change it according to the port you are connecting to, as I am using roboRio, I keep this .kOnBoard, or I change it to another type of port

You can use either the kOnboard which is the port next to the CAN bus port or you can use kMXP which is a few pins in the large MXP connector (use a breakout board for the MXP to make it easier to access.

Be aware of the restrictions described in known issues

My team has never seen a problem with Onboard but choose to never use it - not worth the risk. We have had good success with one device on the MXP I2C but more devices fail for us. We choose not to use I2C at all this year.

1 Like

I would strongly recommend you use the Pi Pico based solution referenced in the known issues page (linked on the previous post) to interface to the sensor, and not use the RoboRIO I2C ports at all.

4 Likes

we use the same sensor, and i would highly recommend you use the proximity function of the sensor over the color. in our experience, the color was always some shade of brown.

for an example of this, refer to some of our code here: crescendo2024/src/main/java/frc/robot/subsystems/ShooterSubsystem.java at d33d2823d002aea347a0d7401072e4471953b7d0 · vikings204/crescendo2024 · GitHub

2 Likes