View Single Post
  #4   Spotlight this post!  
Unread 20-11-2015, 18:29
EmileH's Avatar
EmileH EmileH is offline
it's not a water game, ok?
AKA: Emile Hamwey
FRC #1058 (The PVC Pirates) & SLFF (NE Way You Want It)
Team Role: Programmer
 
Join Date: Dec 2014
Rookie Year: 2011
Location: New England
Posts: 535
EmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant future
Re: Newbie How to control a spike

Do not name your spike object and the cannonFire() method the same thing. I'd change the spike name to cannonSpike if I were you but do whatever suits you best. Also, you will need to call that method (cannonFire) from something. But you will need to create a joystick instance to have a button to press. In your Robot.java file, create an instance of a joystick. To do this, add this line after the "public class Robot extends ___" line:
Code:
Joystick stick;
Add this line after the "public Robot()" (constructor) line:
Code:
stick = new Joystick(0); // new joystick on port 0. Change this if you wish
Then, when you press button 5 on the joystick you will want the code to run the method inside the Cannon subsystem. Add the following lines under the operatorControl method:

Code:
  if(stick.getRawButton(5) == true){
            	Cannon.cannonFire();
            }
This should get you all set from there in terms of programming. You can remove the Command file if you so desire.
__________________
2016-present: High School Student, FRC 1058 PVC Pirates
2016: RiverRage 20 Champions, Battle of the Bay 3 Champions

2013-2015: Middle School Student, FRC 3467 Windham Windup
Reply With Quote