I have successfully tried some simple sketches and the controller is communicating well with the Arduino uno rev3 I have.
I’m now trying to get a bit more difficult.
I want the PS3.getAnalogHat(LeftHatX) to turn on a output when the joystick is in a certain range.
Here’s my example code
#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
int LED = 3;
boolean printAngle;
uint8_t state = 0;
void setup() {
pinMode(LED, OUTPUT);
Serial.begin(115200);
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start"));
while (1); //halt
}
Serial.print(F("\r\nPS3 USB Library Started"));
pinMode(LED, OUTPUT);
}
void loop() {
Usb.Task();
if (PS3.PS3Connected || PS3.PS3NavigationConnected)
digitalWrite(LED, PS3.getAnalogHat(LeftHatX)= 120-155));
else
digitalWrite(LED, LOW);
}
Very simple but I get a Ivalue required as left operand of assignment
I know it’s not written correctly but I can’t find any examples out there for this project
Also know I'm asking to wite digital command from and analog input through the ps3 controller
I'm just asking for help with where to start on the code.
Second thing I want to do is take the other joystick Ps3.getAnalogHAt(LeftHatX)
And use the value 0-255 and convert that to an output either 0-5v using a (rc circuit or DAC chip I have the hardware just need a little help with the code interfacing with the ps3 controller) or 0-5k resistance using a digital pot. I need to figure out each way and try them to find out what will work best for this application.
Thanks,