Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   HELP!! (http://www.chiefdelphi.com/forums/showthread.php?t=84638)

krudeboy51 25-03-2010 00:17

HELP PLEASE!!
 
hi, i am a new programmer on my team, Can anyone please tell me how to program a spike in c++ :confused:

Quote:

class:
????
public:
????
please, some one help!!

Golto 25-03-2010 06:39

Re: HELP!!
 
Define the spike as:
Code:

Relay *[variable here]
Initialize it as:
Code:

[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:
Code:

[variable name]->Set(Relay::kForward)
-OR-
[variable name]->Set(Relay::kReverse)
-OR-
[variable name]->Set(Relay::kOff)


nighterfighter 25-03-2010 06:58

Re: HELP!!
 
That is one way to do it. However, instead of declaring the Relay as a pointer (*) you can do it this way:

Code:

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.

}
}



All times are GMT -5. The time now is 03:37.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi