Go to Post Students dream up the ideas for bots, it is than up to the mentors and engineers to make these dreams a reality. - dddriveman [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 14-01-2017, 18:03
randy_pham randy_pham is offline
Registered User
FRC #0498 (Cobra Commanders)
Team Role: Programmer
 
Join Date: Jan 2017
Rookie Year: 2016
Location: Arizona
Posts: 5
randy_pham is an unknown quantity at this point
Maxbotics Ultrasonic Sensor Not Working



We are trying to use the Maxbotics Ultrasonic sensor as an analog input. However, we are not getting responsive voltages from the sensor.

Code:
package org.usfirst.frc.team498.robot;

import edu.wpi.first.wpilibj.AnalogInput;

public class AnalogUltrasonicSensor2017 {
	AnalogInput AI;
	public AnalogUltrasonicSensor2017(Ports ports) {
		AI = new AnalogInput(ports.ULTRASONIC_SENSOR); // !!!MUY IMPORTANTE!!!
	}
	
	public double GetRangeMM() {
		double output = 0;
		output = AI.getVoltage();
		output = output / 1000; //Measured in millivolts
		output = output / 0.977;
		return output;
	}
	
	public double GetRangeInches() {
		double output = GetRangeMM();
		output = output * 25.4;
		return output;
	}
	
	public double GetVoltage() {
		return AI.getVoltage();
	}
}
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 10:43.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi