Go to Post It is a difficult balancing act - we're engineers because we like to solve problems, and to take a step back and let someone else solve it, with what may be a poorer solution, is darn hard. - DonRotolo [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 25-01-2017, 18:17
Tank1357 Tank1357 is offline
Registered User
FRC #3640
 
Join Date: Jan 2017
Location: Tennessee
Posts: 2
Tank1357 is an unknown quantity at this point
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.
Reply With Quote
  #2   Spotlight this post!  
Unread 25-01-2017, 19:42
AustinShalit's Avatar
AustinShalit AustinShalit is online now
Registered User
AKA: אוסטין
no team (WPILib Suite Developer)
 
Join Date: Dec 2013
Rookie Year: 2008
Location: Los Angeles/Worcester/Israel
Posts: 144
AustinShalit is a glorious beacon of lightAustinShalit is a glorious beacon of lightAustinShalit is a glorious beacon of lightAustinShalit is a glorious beacon of lightAustinShalit is a glorious beacon of lightAustinShalit is a glorious beacon of light
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
__________________
Reply With Quote
  #3   Spotlight this post!  
Unread 27-01-2017, 13:50
WilliamFRC4065's Avatar
WilliamFRC4065 WilliamFRC4065 is offline
Registered User
FRC #4065 (The Nerds of Prey)
Team Role: Programmer
 
Join Date: Jan 2017
Rookie Year: 2016
Location: Florida
Posts: 7
WilliamFRC4065 is an unknown quantity at this point
Talking 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
Reply With Quote
  #4   Spotlight this post!  
Unread 27-01-2017, 13:51
WilliamFRC4065's Avatar
WilliamFRC4065 WilliamFRC4065 is offline
Registered User
FRC #4065 (The Nerds of Prey)
Team Role: Programmer
 
Join Date: Jan 2017
Rookie Year: 2016
Location: Florida
Posts: 7
WilliamFRC4065 is an unknown quantity at this point
Re: If a. Run motor

Quote:
Originally Posted by WilliamFRC4065 View Post
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!!!
Reply With Quote
  #5   Spotlight this post!  
Unread 28-01-2017, 18:27
Tank1357 Tank1357 is offline
Registered User
FRC #3640
 
Join Date: Jan 2017
Location: Tennessee
Posts: 2
Tank1357 is an unknown quantity at this point
Re: If a. Run motor

Thank you so much, this was very helpful.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


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

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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