I need a button code for operating our arm on our robot. Any code would be nice. Thank you.
P.S.- We have a single joystick code, if that matters at all.
I need a button code for operating our arm on our robot. Any code would be nice. Thank you.
P.S.- We have a single joystick code, if that matters at all.
What moves your arm? A motor? Pneumatics? A herd of servos in parallel? The code you need has to control the device you use.
What button are you using? What do you want to have happen when you press the button? The code you want has to implement that.
After you give some real specifications for what you want, we can start giving useful suggestions on how to meet them.
Alrgiht, we have a pneumatic arm with three different cylinders, one for lifting, and two for extension. We need code to operate these three cylinders with one joystick, so we can have another for driving. We need three different buttons to operate each cylinder, the first press to activate the cylinder out, and the second press of the same button to retract it.
Check out this thread.
What you’re looking for is a way to toggle a relay output with a button tap. There were several solutions mentioned.
The code we saw is not working. Where in the Default Code do we put it? Or what is another code?
Fortunately, the white joysticks have lots of buttons! Assuming the joystick is on Port 4 of the OI, the trigger is p4_sw_trig, the thumb button is p4_sw_top, the left hand button on top is p4_sw_aux1, and the right hand button on top is p4_sw_aux2. Pick which three you want to use. I’ll show you how to use the trigger for what you want, assuming you’re using a double solenoid connected to a Spike on Relay 1, and you can go from there.
In the Default_Routine() function in user_routines.c, use this code:
static char last_trig = 0; // this is what the switch state was last time
static char cylinder_state = 0; // this is what we last told the cylinder
if (last_trig == 0 && p4_sw_trig == 1) // the switch was just now pressed
{
if (cylinder_state == 0) // the cylinder was retracted, need to extend
{
cylinder_state = 1; // remember that we're extending it
relay1_fwd = 1; // do whatever it takes to activate the solenoid
relay1_rev = 0;
}
else // the cylinder was extended, need to retract
{
cylinder_state = 0; // remember that we're retracting it
relay1_fwd = 0; // do whatever it takes to reverse the solenoid
relay1_rev = 1;
}
}
last_trig = p4_sw_trig;
Thanks. I think we are going to use the trigger, left hand button on the top, and thumb button.