Can anyone please help me make sense of this code?

I’m trying to control various servo motors and a camera. I am new to programming and have no idea what this means! =(

XC.c (7.15 KB)

your going to have a difficult time getting an arduino to act as a USB host and interface with an xbox / xbox360 controller, I would try something simpler like a ps1 or ps2 controller as they are serial (in a nutshell)

Would a logitech dual action gamepad work? I don't have a PS controller.

Isn't that a usb device too?

Yes, but I need to see how to code it so it can communicate to the devices I mentioned.

The Arduino is a usb client device. Gamepads are client devices. Usb is a Host-Client protocol, so if you want to attach usb gamepads to an arduino, you'll want a usb host shield, then a library like http://www.open.com.au/mikem/arduino/USBJoystick/ - found by googling 'logitech dual action gamepad arduino'.

I believe newer Arduinos (Uno and Mega 2560) can have the Usb interface processor reprogrammed to act as a host too, but I'd go down the shield route, personally.

I will try that. :open_mouth:

This may sound stupid, but is there any way to use the computer. - For example: Could I plugin the arduino and joystick into the computer and have the joysticks output be the arduinos input?

This may sound stupid, but is there any way to use the computer. - For example: Could I plugin the arduino and joystick into the computer and have the joysticks output be the arduinos input?

It's not stupid. Yes, you can do that. All you need is an application on the computer that can read the joystick and write the serial port (that the Arduino is connected to).

I used a RumblePad II through a netbook to an arduino. I used C# for the passthrough. If you’re interested I can post some source and the sketch I used.

Yes Please. :)

Would a wired controller be the same?

I am looking at this code I have and it is way too specific to be much help for anyone. I have been meaning to rewite it a bit so-as to be able to share it. If you know a bit of programming you can pick at it. I will replace the zip and repost when I get a saleable demo. You will need to enter the COM port name and then it should grab the first joystick it finds and send the X and Y to the arduino. There is a sketch in the zip file that will echo the X and Y back to the app.

Joystick Control Sandbox

You may need to install SilmDX for .NET http://slimdx.org/