It seems pretty inexpensive and I am a little afraid of using the Rev based on some of the I2c issues that have been reported.
I have found some pretty good tutorials for this sensor to use with an arduino and could use that as a coprosser if I cannot get it to work directly on the rio.
The arduino code looks pretty basic and does not require any additional libraries so I think it should be easy to port over, that is if you are more of a seasoned programmer than I. The only built in arduino function that I haven’t found on rio/wpilib is pulsein(). Does anyone know if there is a built in version or this, or if not could more knowledgeable than me explain the best way to implement this on the rio.
Attached is a video of the sensor working with the an Arduino.
The semi-period mode of the counter class should do what you need. One difference between it and the pulseIn Arduino method is that pulseIn is blocking, so after changing the color, it will wait until it gets the new measurement. In the roboRIO, the measurement is made in the FPGA and the result of the last measurement is returned. It should be ok to change the color in one robot loop and then read the color the next loop.
It appears you can get that same breakout board from other distributors for cheaper then Amazon. One other note is that the Arduino article shows using a blinder for sensor. That would probably be smart to implement.
Make sure to test this under a few lighting conditions. Take a look at the spectral response from the datasheet:
One concern I’d have is if there is enough infrared blue can start looking like red. Maybe the one on amazon with a ‘lens’ to block out the light (or 3d print something) could help?
I been working on this for a few days. My goal is to connect them to my CheesyArena for auto scoring. I’m using an Arduino to drive the signals and have had the Arduino driving DIO on the Rio.
Now that @Joe_Ross pointed out the function of the counter I’ll give that ago too.(for robot integration)