View unanswered posts | View active topics It is currently Thu Oct 30, 2014 9:12 am






Reply to topic  [ 7 posts ] 
Motors and Buttons -- Joystick Control 
Author Message
Rookie

Joined: Tue Oct 20, 2009 9:49 pm
Posts: 2
Post 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
Thanks in advance!
-Andy


Tue Oct 20, 2009 10:04 pm
Profile
Expert

Joined: Mon Oct 27, 2008 9:59 pm
Posts: 139
Post 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
Profile
Professor

Joined: Fri Sep 19, 2008 1:22 am
Posts: 200
Post 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
Profile
Rookie

Joined: Tue Oct 20, 2009 9:49 pm
Posts: 2
Post 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
Profile
Rookie

Joined: Sun Jan 03, 2010 8:23 pm
Posts: 5
Post 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
Profile
Professor

Joined: Fri Sep 19, 2008 1:22 am
Posts: 200
Post 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
Profile
Rookie

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


Fri Jan 08, 2010 8:20 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 7 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


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

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.