USB game controller used to control motor and light

I’m new to Arduino. I’m trying to control a motor and two lights (turn them on and off) using a USB game controller connected to the arduino and/or the computer. Any help would be great!

Identify all parts with links so we know what you are using would be a good start.


I'm using the Sunfounder mega 2560 board.

The logitech gamepad F310
Getting Started - Gamepad F310 – Logitech Support + Download .

The lights use a flash light bulb and external battery.

Finally, I'm using HG2223 KV1800 Brushless Motors

I'm thinking I will need a USB shield to fit onto the 2560 board to plug the logitech gamepad into.


I'm thinking I will need a USB shield to fit onto the 2560 board to plug the logitech gamepad into.

So what have you done on that part? Possible info below.

Is there something you really like about the game controller you want to use? As mentioned in this thread, there are lots of game controllers which don't require any special hardware to interface with an Arduino.

Of course you have the option of using any sort of joystick you want if you make your own controller.

I think this joystick is really cool and it seems like I post a picture of it every other day or so.

I like the game controller that I specified only because it seems to meet the needs of each function I will need. By that I mean it has a couple of buttons that I could use to turn a couple of lights on/off and two joysticks that I could use to ultimately control 3 motors. The project is a small submarine. Two thruster motors on either side of the hull will provide forward thrust (joystick forward), turning right (joystick right) left motor on/ right motor off, same for turning left except opposite. A separate joystick controlling a third motor (joystick forward) dive, (joystick back) surface. That's the only reason I specified that controller. The other advantage of working with a game controller is it's all-in-one fits in my hand. I don't have to make a housing for multiple joysticks and buttons. I'm now looking at the Playstation 2 and Gamecube that your thread recommends. I'm a aero engineer so the electronics are a bit of a mystery to me at this point.

I really like the original Sony PlayStation 2 controller but the cheap wireless clones I've tried have been pretty bad.

Here are a couple reviews on game controllers.

I just thought of something. You'll likely want your own radio system won't you? In this case a wired controller should be fine connecting with the transmitting Arduino.

There's a good chance it's possible to get the USB game controller working with an Arduino, but it seems like a lot of extra work if a Sony PlayStation 2 controller would do the job.

The only game controller I've used with an Arduino so far has been a Wii Nunchuck. I really like Nunchucks as controllers. The accelerometer can be used for additional input. I've flown a RC helicopter with a Nunchuck. I used the joystick to control roll and pitch and the accelerometer to control yaw and throttle.

With my hexapod, I can can change modes by pressing one of the buttons, moving the Nunchuck to a particular orientation and then releasing the button. The mode will be selected based on the orientation when the button was released. This lets you control lots of different parameters by changing modes. Of course there are some parameters you'd like to control all at the same time (like on a helicopter). While I was able to fly the helicopter with a Nunchuck, it was certainly not any easier than flying the helicopter with two joysticks. There are times when it's convenient to have a one handed controller.

The PlayStation 2 controller has pressure sensitive buttons. I've always wanted to try using these buttons as proportional control devices. I'd think a PS2 controller would likely be a good fit for your application and it would be much easier to use with an Arduino than using a USB controller (at least that's the impression I get from reading about these controllers, as I said, I've only used the Nunchuck with an Arduino).

Thanks for the input. I'll look around either on ebay or a local gaming store for the PlayStation 2 controller. I'm guessing there is only one kind of PlayStation 2 controller or any difference wouldn't be significant. I also found the Bill Porter library that I think will help me too. Until I pick up the controller I'll work to get that installed and understand it.

I'm guessing there is only one kind of PlayStation 2 controller or any difference wouldn't be significant.

I wish that were the case. I've purchased a total of four different PlayStation 2 controllers.

The first one was a generic controller from SparkFun. Rather than 8-bit analog output from the joysticks, the controller only provided 5-bits of control. You can read what I had to say about the controller in the comments of the product page (ddegn is my username at SparkFun).

Disappointed to only get 5-bits of control from the joysticks, I purchased an official Sony controller. The Sony controller works great. It's the only PlayStation 2 controller I've found so far which works well.

I tried two different wireless PlayStation 2 controllers but I thought they were both very poor controllers. While the output from the joysticks was a full 8-bits, the area which provided proportional control was so small the joystick was pretty much worthless for proportional control.

The two wireless joysticks were sold under different brands but it was obvious they were both made by the same manufacturer. The review I linked to earlier gives a bit more detail about the wireless controllers. I would much rather have the 5-bit controller from SparkFun than the wireless controllers.

I asked fellow Robot Rebels members if they had suggestions for PlayStation 2 controllers. You can read the discussion here.

I've used my Sony PlayStation 2 controller with a touchscreen. The touchscreen can display telemetry from the robot.

While I think the above controller is cool, the program is really complicated. I think the touchscreen and PS2 controller make a nice controller but it's kind of bulky. I find I often prefer the simplicity of a Wii Nunchuck. The Arduino code I originally found for the Nunchuck didn't work very well so I wrote my own version. I'm pretty sure there are other version of Nunchuck code which works fine. I just didn't know about these other version at the time I wrote my version.

I've heard good things about the Bill Porter library. I plan to use it myself.

The USB controller you originally planned to use, might work fine with an Arduino. It's just been my experience USB devices are generally harder to use with microcontrollers than devices which use microcontroller friendly protocols.