|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. |
|
#2
|
||||
|
||||
|
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 |
|
#3
|
||||
|
||||
|
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; 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);
}
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 |
|
#4
|
||||
|
||||
|
Re: If a. Run motor
Quote:
|
|
#5
|
|||
|
|||
|
Re: If a. Run motor
Thank you so much, this was very helpful.
![]() |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|