Control brushless motor with Xbox Controller

Hi guys!
I'm pretty new to Arduino but really excited by the possibilities! I'm currently working on a sketch to control a brushless motor with an Xbox 360 controller.

When trying to use the button presses from the controller, this seems to be the format I've seen from the couple of examples I've found:



Xbox.getButtonPress(L2, i)

In those snippets, what do the ,0 and ,i do? I would have thought the code would just be Xbox.getButtonPress(L2)


My sketch so far:

#include <XBOXRECV.h>
#include <Usb.h>
#include <Servo.h>

USB Usb;
Servo motor1;

int motor_power = 0; // working value to control the power of the motor
int motor_output = 0; //value from 0-179 which is sent to ESC
int const motor_output_pin = 9; // pin which the ESC is connected to
int const range = 10000; 

void setup(){
  if(Usb.Init() == -1) { //USB.Init will return -1 for shield disconnected, and 0 if connected
    while(1); //halt until shield is connected

void loop(){
  motor_power = motor_power + XboxRCV.getButtonPress(R2);
  if(motor_power > range)
  motor_power = range;
  motor_power = motor_power - XboxRCV.getButtonPress(L2);
  if(motor_power < 0)
  motor_power = 0;
  motor_output = map(motor_power, 0, range, 0, 179);

I'm not able to test it out yet as still waiting on my USB Host Shield, but if anyone can spot any major errors I'd appreciate it!

Ah, thanks to Kristian - the ",0" specifies which controller then button press should be read from in case anyone else is wondering the same thing!