Log in

View Full Version : HELP!!


krudeboy51
25-03-2010, 00:17
hi, i am a new programmer on my team, Can anyone please tell me how to program a spike in c++ :confused:


class:
????
public:
????


please, some one help!!

Golto
25-03-2010, 06:39
Define the spike as:
Relay *[variable here]

Initialize it as:
[variable name used above] = new Relay([Relay port it's plugged into on the DSC])

To use it, place where needed in your code like this:
[variable name]->Set(Relay::kForward)
-OR-
[variable name]->Set(Relay::kReverse)
-OR-
[variable name]->Set(Relay::kOff)

nighterfighter
25-03-2010, 06:58
That is one way to do it. However, instead of declaring the Relay as a pointer (*) you can do it this way:

class Team1771Robot : public SimpleRobot {

RobotDrive driveTrain;
Joystick leftStick;
Joystick rightStick;
Shooter mainShooter;
Relay mySpike; //Declare your spike's name here

public:
Team1771Robot(void):
driveTrain(LEFT_DRIVE_MOTOR_PORT, RIGHT_DRIVE_MOTOR_PORT),
leftStick(LEFT_JOYSTICK_PORT),
rightStick(RIGHT_JOYSTICK_PORT),
mainShooter(SHOOTER_TENSION_PORT, SHOOTER_RELEASE_PORT),
mySpike(MYSPIKE_PORT) //Put whatever slot the spike is.



{



}
;




Later on in your code, say, in the teleop, you can say

void OperatorControl()
{
while(isOperatorControl() && !isNotDisabled())
{

mySpike.Set(Relay::kOff); //Or forward, reverse, etc.

}
}