Quote:
Originally Posted by TFleig78
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);
}