View Single Post
  #2   Spotlight this post!  
Unread 13-02-2015, 10:48
Oromus's Avatar
Oromus Oromus is offline
Lead Programmer, Community Liason
AKA: Ryan
FRC #1902 (Exploding Bacon)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2013
Location: Florida
Posts: 82
Oromus is a splendid one to beholdOromus is a splendid one to beholdOromus is a splendid one to beholdOromus is a splendid one to beholdOromus is a splendid one to beholdOromus is a splendid one to behold
Re: VEX Ultrasonic Sensor

You may want to take a look at the WPILib Java documentation on Ultrasonic sensors. I personally haven't used them, but it looks like (based off of the Javadocs) that you code should look similiar to this:

Code:
//Setting up the sensor
Ultrasonic ultra = new Ultrasonic(0, 1); //Make a new Ultrasonic Sensor on "pingChannel" 0 and "echoChannel" 1.
ultra.setAutomaticMode(true); //If you don't want to have to call ultra.ping() whenever you want to check for values
ultra.setEnabled(true); //Enable the Ultrasonic sensor

//Whenever you want to read values:
double millis = ultra.getRangeMM(); //Get distance in millimeters
double inches = ultra.getRangeInches(); //Get distance in inches
Reply With Quote