View unanswered posts | View active topics It is currently Fri May 06, 2016 12:27 am

 Page 1 of 1 [ 7 posts ]
 Print view Previous topic | Next topic
Motors and Buttons -- Joystick Control
Author Message
Rookie

Joined: Tue Oct 20, 2009 9:49 pm
Posts: 2
Motors and Buttons -- Joystick Control
So I am trying to get a motor to be controlled by several different joystick buttons, basically assigning different power levels to each button. This is the scenario I am trying to create: button 1 is low power, button 2 is medium power, and button 3 is high power, and when all 3 buttons are not in use the motor should not spin. I have been trying all day and not a single code I have created does all functions. Please help... I need some code! lol
-Andy

Tue Oct 20, 2009 10:04 pm
Expert

Joined: Mon Oct 27, 2008 9:59 pm
Posts: 139
Re: Motors and Buttons -- Joystick Control
It sounds like you're looking for a simple set of IF/ELSE statements. Something along the lines of:
 Code:if(joy1Btn(1))  {  motor[andysMotor] = 25; //low power}else if(joy1Btn(2)){  motor[andysMotor] = 50; //medium power}else if(joy1Btn(3)){  motor[andysMotor] = 100; //high power}else{  motor[andysMotor] = 0; //stop}

Tue Oct 20, 2009 10:18 pm
Professor

Joined: Fri Sep 19, 2008 1:22 am
Posts: 200
Re: Motors and Buttons -- Joystick Control
The problem with that solution is that the robot would stop as soon as you release the button. You will probably not want to use a final "else" clause to stop the motor(s). Instead, choose a button to represent "stop" and test for that.

_________________
Jeff McBride
Benson Robotics Club

Wed Oct 21, 2009 12:19 am
Rookie

Joined: Tue Oct 20, 2009 9:49 pm
Posts: 2
Re: Motors and Buttons -- Joystick Control
Thank you so much! The only thing I was missing was the "else if" part.
Thanks!!!!
-Andy

Wed Oct 21, 2009 9:09 am
Rookie

Joined: Sun Jan 03, 2010 8:23 pm
Posts: 5
Re: Motors and Buttons -- Joystick Control
Hi

We would like to know if you guys could post the values for each buttons in RobotC. on the old version, under 'help', they showed us the values. in the new one they don't. we aren't sure if we have the right ones from our memory. all we are sure are 1=1 2=2 3=4 4=16 if you could plz post a response that would be great!!!!!!!!

(Hi Mr McBride)

Thank You

Untitled 8 Team # 3515

Mon Jan 04, 2010 7:26 pm
Professor

Joined: Fri Sep 19, 2008 1:22 am
Posts: 200
Re: Motors and Buttons -- Joystick Control
#define button1 0x01
#define button2 0x02
#define button3 0x04
#define button4 0x08
#define button5 0x10
#define button6 0x20
#define button7 0x40
#define button8 0x80
#define button9 0x100
#define button10 0x200

_________________
Jeff McBride
Benson Robotics Club

Mon Jan 04, 2010 10:16 pm
Rookie

Joined: Sun Jan 03, 2010 8:23 pm
Posts: 5
Re: Motors and Buttons -- Joystick Control
Thank you so much. those weren't the number that we thought of so thanks!!!!!!!!!!!!

Fri Jan 08, 2010 8:20 pm
Display posts from previous:  Sort by
 Page 1 of 1 [ 7 posts ]

#### Who is online

Users browsing this forum: No registered users and 1 guest

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ ROBOTC Applications    ROBOTC for LEGO MINDSTORMS       Third-party sensors    ROBOTC for CORTEX & PIC    ROBOTC for VEX IQ    ROBOTC for Arduino    Robot Virtual Worlds    Multi-Robot Communications    Issues and Bugs Competitions & Partners    Mini Urban Challenge    CS2N Robot Virtual Worlds Competitions       VEX Skyrise Competition 2014-2015       VEX Toss Up 2013-2014       FTC Block Party! 2013-2014    Competitions using VEX - BEST, TSA, VEX, and RoboFest!    FTC Programming    RoboCup Junior and Other ROBOT Competitions Virtual Brick Robotics Discussions    General Discussions    Project Discussions Off-Topic ROBOTC Forum & ROBOTC.net Suggestions/Feedback    ROBOTC Forums Suggestions/Comments    ROBOTC.net Suggestions/Comments       NXT Programming: Tips for Beginning with ROBOTC       VEX Programming: Tips for Beginning with ROBOTC    2013 Robotics Summer Of Learning       VEX Toss Up Programming Challenge       FTC Ring It Up! Programming Challenge    International Forums       Spanish Forums          ROBOTC for MINDSTORMS          ROBOTC for VEX       French Forums          ROBOTC pour Mindstorms          ROBOTC pour IFI VEX       Japanese Forums （日本語のフォーラム）       German Forums    2015 Spring Carnival Event    PLTW (Project Lead The Way)    Robotics Merit Badge    2014 Robotics Academy Summer of Learning