Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   If a. Run motor (http://www.chiefdelphi.com/forums/showthread.php?t=154247)

Tank1357 25-01-2017 18:17

If a. Run motor
 
Hello,

I am fairly new to FRC and I am supposed to be the programmer for my team. I am currently working on a program that will run a motor controlled by PWM for two seconds, if the button A on a Xbox controller is pressed. I have read articles and forums that explain bits and pieces on how to do it, but I am having problems putting those pieces together into a working program. I learn best by example, so if somebody could give me an example of the code for this program, it would be greatly appreciated.

AustinShalit 25-01-2017 19:42

Re: If a. Run motor
 
I would watch these videos about RobotBuilder. Pay close attention to the Claw subsystem.

https://www.youtube.com/watch?v=k7Pa...ObeKzp&index=1

WilliamFRC4065 27-01-2017 13:50

Re: If a. Run motor
 
Coming from a person who has scoured screen steps for the exact same thing...
(These are just examples)
Code:

//First declare the joystick somewhere as a pointer
frc::Joystick* controller;

Then,
Code:

//Make a bool and assign it to the controllers button in Telop
bool a;

Code:

//Pretend 1 is A for now
a = controller->GetRawButton(1);
if(a){
motor1->Set(0.5);
}

Now I just gave you examples. You need to put them in the right places though:
Code:

//The bool goes into the robot init
//The joystick definition goes in the private section of the robot class
//And the code to execute it goes in telopPeriodic


WilliamFRC4065 27-01-2017 13:51

Re: If a. Run motor
 
Quote:

Originally Posted by WilliamFRC4065 (Post 1637115)
Coming from a person who has scoured screen steps for the exact same thing...
(These are just examples)
Code:

//First declare the joystick somewhere as a pointer
frc::Joystick* controller;

Then,
Code:

//Make a bool and assign it to the controllers button in Telop
bool a;

Code:

//Pretend 1 is A for now
a = controller->GetRawButton(1);
if(a){
motor1->Set(0.5);
}

Now I just gave you examples. You need to put them in the right places though:
Code:

//The bool goes into the robot init
//The joystick definition goes in the private section of the robot class
//And the code to execute it goes in telopPeriodic


ONLY IF YOU ARE USING A ITERITIVE!!!

Tank1357 28-01-2017 18:27

Re: If a. Run motor
 
Thank you so much, this was very helpful.:D


All times are GMT -5. The time now is 21:58.

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