Log in

View Full Version : Using an Analog Ultrasonic Sensor


Maxchrist
09-02-2014, 11:54
Hi, I have been trying to use a maxbotix ultrasonic sensor to get a distance using java. The sensor is on an analog channel so it seems that I cannot use the frc api for the ultrasonic sensor. I have the math worked out, and it prints a distance in inches, however the voltage on the sensor is not changing when I move the sensor, which means it is not sending out signals. How can you start the sensor and make it send out sonar signals? Or if I am not going about this the right way, is there a better way to do this? this is what I have so far:
16178

Thorn
09-02-2014, 12:32
We had a similar issue with the Analog sensor. We discovered that our analog breakout board went bad and after we swapped it we could see the voltage values change in response to object detection.

We did a simple test like you did, but we were tossing the output into SmartDashboard.
Where does System.out.println(x) go? Is there an easy way to send console output back to the computer for display or log?

Maxchrist
09-02-2014, 12:37
yes, you can see System.out.println() in netbeans in the output window if you keep it open alongside the drive station.

sailorjoe
09-02-2014, 13:11
I think your code needs a small adjustment. It looks to me like it gets a single range value and keeps printing it over and over in the while loop. Move the range statements inside the while loop. Good luck!