I'm using Uno and doing som testing with the PS3 controller connected over usb wire (Do not have BT dongle yet). Using usb host shield library. have no trouble using buttons , both analog and digital, and also gyro and manage to control a servo . Have tried the library on a mini, works well there also.
I want to use an input on the Arduino to activate the rumble motor in the PS3 controller.
I cant figure out the right code syntax to do this, have searched but doesn't find any code examples on this?
Anyone done this?
current test sketch
just one servo to control and one led output
#include <PS3USB.h>
USB Usb;
/* You can create the instance of the class in two ways */
PS3USB PS3(&Usb); // This will just create the instance
//PS3USB PS3(&Usb,0x00,0x15,0x83,0x3D,0x0A,0x57); // This will also store the bluetooth address - this can be obtained from the dongle when running the sketch
#include <Servo.h>
Servo servo; // create servo object to control a servo
const uint8_t LED = 2;
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
pinMode(LED, OUTPUT);
Serial.begin(115200);
if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start"));
while(1); //halt
}
servo.attach(9); // Use pin 9, as signal pin
Serial.print(F("\r\nPS3 Bluetooth Library Started"));
}
void loop() {
Usb.Task();
if (PS3.PS3Connected)
digitalWrite(LED, PS3.getButtonPress(CROSS));
else
digitalWrite(LED, LOW);
if (PS3.PS3Connected)
servo.write(map(PS3.getAngle(Pitch), 0, 359, 170, 0));
else
servo.write(85); // Set to middle position
}