I had to fill in a few gaps, but this wasn't as hard as I might have thought it to be. Still, there wasn't a guide so here's mine for the next guy. I found Oleg's and Laszarus's stuff and had already been working with the PS3 controller as a wired controller but wanted to shift to a wireless mode. I had the code, but it seemed like I was missing an important step or two.
For those of you that don't know, the pairing process of a PS3 controller to a host is different than most other Bluetooth devices like mice, keyboards, phones, etc. The PS3 controller needs to have the MAC of the host sent to it via USB first, then the controller will initiate the connection to the host. There's also a pinhole reset button on the bottom of the controller. That should wipe the address if you ever feel the need to.Article/OP:http://www.circuitsathome.com/mcu/bluetooth-code-for-arduino-usb-host/comment-page-1#comment-15294How-to:
You have to go through an iterative process to get things going. First off the USB_Host_shield_2.0 library **does** work with Bluetooth now. That was unclear in the OP and comments due to their age (page and comments, not people). I managed to get this working with an Arduino MEGA ADK Rev 3 and a Cirago BTA-3210.Step 1.
You need to run the PS3BT sketch with the Bluetooth (BT) dongle plugged in if you don’t have the MAC address already. If you do have the MAC, you can skip this part. Some dongles have the address on a sticker; some are too small for that. Mine was too small so I ran the sketch to find the MAC address. The MAC will be displayed in the Serial Monitor.Step 2.
Hard code the MAC into the program in the commented out line:
// PS3BT PS3(&Btd,0×00,0×15,0×83,0x3D,0x0A,0×57); // This will also store the bluetooth address – this can be obtained from the dongle when running the sketch.
Make sure to uncomment the line too so that it will take effect.
This will send this address to the PS3 controller when connected. All you need to do is replace the hex digits after the “0x”. Make sure not to fat-finger it.
You'll want to comment out the other constructor so they don't interfere with each other:
PS3BT PS3(&Btd); // This will just create the instanceStep 3.
Remove the BT adapter and plug the USB cable into the PS3 controller and the USB host port or your arduino setup. USB is hot swappable but you can remove power first if you like. Note that while the hardware is hot swappable, the software probably isn't so you'll need to reboot for the arduino to see anything new plugged in.
I found that with the ADK I would have to plug in the BT adapter or the PS3 controller AFTER connecting the arduino to the PC. Otherwise the PC would not recognize the arduino COM port properly. I suspect it had to do with power draw, but never pursued the problem.Step 4.
Reboot (or boot) your arduino. The modified code will send that address to the PS3 controller so that the controller can initiate the connection to the adapter. This is a similar process to how you pair a controller to a PS3.Step 5.
Remove the USB cable from the PS3 controller to the arduino and plug your BT adapter back in.Step 6.
Reboot/boot your arduino.Step 7.
If it’s going to work, it should work. I verified it working by opening the serial monitor. The sample sketch shows you the button presses and certain values sent to the arduino.
The PlayStation button initiates the pairing. You might see all the LEDs flash at once for a bit while it gets started.