SHARE
TWEET
Team 2601 sonar unit test
a guest
Apr 4th, 2014
9
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- /*----------------------------------------------------------------------------*/
- /* Copyright (c) FIRST 2008. All Rights Reserved. */
- /* Open Source Software - may be modified and shared by FRC teams. The code */
- /* must be accompanied by the FIRST BSD license file in the root directory of */
- /* the project. */
- /*----------------------------------------------------------------------------*/
- package edu.wpi.first.wpilibj.templates;
- import edu.wpi.first.wpilibj.SimpleRobot;
- import edu.wpi.first.wpilibj.Ultrasonic;
- /**
- * The VM is configured to automatically run this class, and to call the
- * functions corresponding to each mode, as described in the SimpleRobot
- * documentation. If you change the name of this class or the package after
- * creating this project, you must also update the manifest file in the resource
- * directory.
- */
- public class RobotTemplate extends SimpleRobot {
- Ultrasonic sonar1 = new Ultrasonic(2, 1);
- Ultrasonic sonar2 = new Ultrasonic(4, 3);
- /**
- * This function is called once each time the robot enters autonomous mode.
- */
- public void autonomous() {
- }
- /**
- * This function is called once each time the robot enters operator control.
- */
- public void operatorControl() {
- sonar1.setEnabled(true);
- sonar1.setAutomaticMode(true);
- sonar2.setEnabled(true);
- sonar2.setAutomaticMode(true);
- while(isOperatorControl() && isEnabled()){
- System.out.println(sonar1.getRangeInches() + ", " + sonar2.getRangeInches());
- }
- }
- /**
- * This function is called once each time the robot enters test mode.
- */
- public void test() {
- }
- }
RAW Paste Data
