I’m having a little issue with my IR sensor code. We are trying to use the IR sensors to see how many power balls we have on board and index balls through out system. We are using Sharp GP2Y0D805Z0F Digital Distance Sensors from Adafruit. Since they’re a digital input, it should just be like a limitswitch, right? Therefore like IR1.get() would return false when nothing is there and true when something is there. We know that they’re wired correctly because they have an LED on the back that lights up when the beam is broken.Am I thinking about this in the right way? I can upload code if anyone wants to see it.
We use Beam break sensors (IR sensors that are similar to what garage doors have at the bottom). Those DigitalInputs actually are true when there is nothing between them, and false when something is there.
I would recommend just using something like smartdashboard to view what they are doing, and make sure that when they change you see the values change the way you expect.
Those will still work in disabled() so you can safely do it without your motors turning on.
Per the Specs on the Adafruit Product Page:
So it would be false (low) on detect, and true (high) otherwise.
Most of these IR Photoelectric sensors are like that, from the Beam Break sensors, to the Sharp Digital/Analog Sensors to those generic yellow Reflection Diffuse sensors.
What I recommend is writing a method to return the state of the sensors that includes the inversion, ie: