Could someone please help me? I’ve been trying to figure out how to program the joystick buttons to make the motors move. I looked through the code samples, and the default code and I found nothing that I can understand properly.
My past experience with C is MikroC which is different than programing the FIRST FRC robots.
ok, i’ll assume you’re using port 1 on the operator interface (OI). just because i’m not sure what you know up to this point (and who’s reading) i’ll just give a brief intro.
as you know, the port your joystick is plugged into is referrred to as pX_something, so it will be p1_…
the analog outputs are
p1_y, the y-axis,
p1_x, the x-axis,
p1_wheel, p1_aux …these are not used as far as i know on the KOP joysticks (possibly the hat on the top?), but they ARE used with the USB ckicklet if you’re using that…
now, the analog buttons are:
p1_sw_trig, the trigger,
p1_sw_top, one of the buttons, i’m not sure which, as with
p1_sw_aux1 and p1_sw_aux2.
Are you using a Robotics IDE (ROBOTC, EasyC, etc.), or are you using a regular C editor? I’ve found EasyC to be just that, easy. If you are this early on in the programming, you can still switch over to EasyC (or another), and have that much already taken care of for the programming, so you can focus on other things like figuring out the best way to pull off Hybrid Mode.
In EasyC, you could do it in about 6 lines of code.
EDIT: By the way, yes; the p1_wheel does refer to the “hat”, and I believe that there is also p1_sw_thumb for the thumb button (or would that be what p1_sw_top goes to?)
p1_sw_top is the top button on CH flightsticks and, I believe, one of the buttons on the top of the AVB Top Shots. I think the thumb button is either another trigger or top button… the wiring in those AVB sticks is darn confusing.
Well, actually, we’re using two AVB (or is it ADB? It looks kind of like that :yikes: ) sticks for our OI, and using EasyC for programming, we don’t need to use the p1_sw_(fill in the blanks) variables, as we can just use a single function to bind everything together. It hurts my pride acquired from slaving over the Source Engine code to use such simplified functions, thus limiting my amount of precise control, but it goes a lot faster, and it works.
EDIT: And those six lines set up the entire operator interface. Just a by-the-way.
I can name that tune in one note…I mean, I can write that function in one line:
pwm01 = p1_sw_top?254:127;
Anyway, Shivang, if you give some more detail about what you want to accomplish, we can give better advice. Which buttons do you want to use, and what do you want the motors to do when you use them?