View Single Post
  #1   Spotlight this post!  
Unread 11-09-2012, 17:47
4085's Avatar
4085 4085 is offline
Technical Difficulties
AKA: Sebastian Brosious
FRC #4085 (Technical Difficulties)
Team Role: Programmer
 
Join Date: Feb 2012
Rookie Year: 2012
Location: Reynoldsburg, Ohio
Posts: 14
4085 is an unknown quantity at this point
Java, The Next Fronteir

Team 4085 enters the next generation of programming, Java, a complex and intricate language. One programmer beta testing the idea by re-writing our robots programming from labveiw to Java. One stepping stone this poor Programmer that knows little to nothing about to java to know, how to make buttons for joysticks.

Please aid me in my quest to program them all. (pokemon, hackers edition)
Code:
/*----------------------------------------------------------------------------*/
/* 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.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.SimpleRobot;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.Jaguar;
import edu.wpi.first.wpilibj.Victor;
import edu.wpi.first.wpilibj.buttons.JoystickButton;
/**
 * 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 Team4085Robot extends SimpleRobot {
    
    RobotDrive Drive = new RobotDrive(1, 2);
    Joystick leftStick = new Joystick(1);
    Joystick rightStick = new Joystick(2);
    Jaguar leftMotor = new Jaguar(1);
    Jaguar rightMotor = new Jaguar(2);
    Jaguar pickupMotor = new Jaguar(3);
    Victor indexMotor = new Victor(4);
    Jaguar shootingMotor = new Jaguar(5);
    Jaguar armMotor = new Jaguar(6);
    JoystickButton button1 = new JoystickButton(leftStick, 1);
    
    /**
     * This function is called once each time the robot enters autonomous mode.
     */
    public void autonomous() {
        for (int i = 0; i < 4; i++) {
            Drive.drive(0.5, 0.0);  // drive 50% forward speed with 0% turn
            Timer.delay(2.0);       // Wait 2 seconds
            Drive.drive(0.0, 0.75); // drive 0% forward with 75% turn
            Timer.delay(0.75);      // wait for the 90 degree turn to complete
        }
        Drive.drive(0.0, 0.0);       // drive 0% forward with 0% turn (stop)
    }

    /**
     * This function is called once each time the robot enters operator control.
     */
    public void operatorControl() {
        while (isOperatorControl() && isEnabled())  // loop during enabled teleop mode
        {
            Drive.tankDrive(leftStick, rightStick); // drive with the joysticks
            Timer.delay(0.005);
        }   
    }
}
__________________
_______________________________________________

WE ARE...

Raiders!
Reply With Quote