View Single Post
  #4   Spotlight this post!  
Unread 16-01-2015, 10:03
N00bfirst N00bfirst is offline
Registered User
FRC #4992
 
Join Date: Dec 2013
Location: Milton
Posts: 8
N00bfirst is an unknown quantity at this point
Re: A relatively dumb question...

Quote:
Originally Posted by TFleig78 View Post
Use:

Code:
AnalogInput ultraSonic = new AnalogInput(0);
Then to get a reading:

Code:
ultrasonic.getVoltage();
Then you need to scale the voltage (0-5) to a distance, using a constant which should be in the documentation for the ultrasonic sensor.
How would I use that for the input and output?
This is our code.

AnalogInput inUltra = new AnalogInput(0);
AnalogOutput outUltra = new AnalogOutput(0);
inUltra.getVoltage();


Ultrasonic ultra = new Ultrasonic(0,0);
ultra.setAutomaticMode(true);
double range = ultra.getRangeInches();
String what = Double.toString(range);

for(int i = 1; i < 10; i++){
SmartDashboard.putNumber(what, range);
}
Reply With Quote