Joysticks question???

Hi guys

I have a question regarding the joysticks

can you program the buttons on the joysticks to functions?

thanks

I’m pretty certain you can. I am almost certain that I have seen other teams do this in the past. But honestly, I am not certain. I advice you to wait for someone else to respond, but I am almost certain.

I’m not certain what you are asking, but I’ll give it a shot. I think you are essentially saying “Can I use the joystick buttons in my code?,” if so, the answer is yes.

thank you, i understand that. But i was wondering how you program it to do something???


if (p1_sw_trig)
{
  // do something when the trigger switch on the joystick
  // connected to port 1 of the OI is pressed
}

The OI Reference Guide explains all the available joystick button names for use with the IFI default code. easyC uses a different naming convention, which is explained in the help for the functions that read OI switches.

Well, it’s really easy, especially if you are using easyC. What they are are just digital inputs to the OI, which reads them similar to a limit switch, either a 1 or 0 depending on whether the switch is open or closed. With easyC, you can use the OI Digital Input located under the RC Control section of the interface to assign the switch to a variable. Then, you can use an If statement to program it to do something for ex., and I apologize if the format isn’t correct since easyC takes care of that

if (trigger_switch == 1)

 motor_output = 255;

else

motor_output = 127;

I think that’s right… but it’s saying if you press a button that has been declared “trigger_switch” the motor that motor_output is associated with will run full bore one direction, and if let up on the trigger, it will stop.
Malhon

so the joysticks buttons can be programmed using the “if” option on easy c??

Yes, your first step is to use the OI Digital input block to get the reading off the joystick. Then you can assign the button to an unsigned char variable, and then use the if statement to “test” the variable. Now, if you decide to use the thumbstick on the joystick, that is a little different, as that thumbstick is actually a four or eight (I can’t remember) position analog input. for ex. If you point the stick up, you might get a reading of 90, but if you point it left, you might get a 500 or something. In that case, you will use the OI analog input, but same basic principle.

can i hook up the limit switches with the joystick??

is there anyway that this is possiblE

another question

how am i suppose to connect the limit switch to the relay outputs??? what kind of wire do i need??? be specific please!

You don’t hook the limit switches up to the joystick, although you can, limit switches are generally ment to be hooked up to the digital input section of the robot controller via pwm style cable. You can use this the same way as the joystick. If you want to hook up a switch to the joystick, you need to do some custom wiring and hook the switch up to the appropriate pins on a DB 15 game controller plug. Here’s a link with pinouts and how joysticks work: http://www.epanorama.net/documents/joystick/pc_joystick.html
Good Luck
Malhon