Hi, we are trying to get a reading from our MaxRobotix Sensor that we have plugged into pin 1 of the Analog input. We are using java (NetBeans) for programming. Some of our code:
Declaring variable:
public static final Button ultrasonicSensor = new AnalogIOButton(1);
And inside out Autonomous section, we simply print out ultrasonicSensor.get();
It would be greatly appreciated if someone could help us get a reading from our sensor so that we can work with it
To get inches from the sensor I THINK you need to multiply the output voltage by 100. again I’m not positive. This is info I carried over from Labview. I see no reason it would be different.
Hey,
So we used an unltrasonic sensor on two of the robots I worked on, and both times we used the .get() method, it returns integers that correspond to distance (in an arbitrary unit). Should work fine either way.
As for your problem, we noticed that we got strange issues when we had something connected to both analog 1 and 2, we’re still not sure why, but if both were connected one or both wouldn’t work (I don’t remember the exact symptoms). We found this problem when working with a gyro, so it could have been specific to a gyroscope, but it might not be. Regardless, you could try switching the port you are using.
Also, I just realized you are using this as a AnalogIOButton object? Is this a sensor on the driver station or on the robot? If this sensor is plugged into the cRio Analog Card (which is what I had assumed, and the above information is referring to), then I believe this should be an AnalogChannel Object. If not, what is the purpose of the sensor? and what is it’s use in autonomous mode, because driver station inputs are disregarded in autonomous?