Oh I totally missed that!
I got it working using the following code:
#include <Servo.h>
#include <PS2X_lib.h> //for v1.6
PS2X ps2x; // create PS2 Controller Class
int error = 0;
byte type = 0;
byte vibrate = 0;
Servo Signal1;
Servo Signal2;
int Input1 = 1500;// creates servo object
int Input2 = 1500;
void setup()
{
Serial.begin(57600);
Signal1.attach(6); //the pin for the servo control
Signal2.attach(7);
error = ps2x.config_gamepad(13,11,10,12, true, true); //setup pins and settings: GamePad(clock, command, attention, data, Pressures?, Rumble?) check for error
if(error == 0)
Serial.println("Controller found! You may now send commands");
else if(error == 1)
Serial.println("No controller found, check wiring, see readme.txt to enable debug. visit www.billporter.info for troubleshooting tips");
else if(error == 2)
Serial.println("Controller found but not accepting commands. see readme.txt to enable debug. Visit www.billporter.info for troubleshooting tips");
else if(error == 3)
Serial.println("Controller refusing to enter Pressures mode, may not support it. ");
type = ps2x.readType();
switch(type)
{
case 0:
Serial.println("Unknown Controller type");
break;
case 1:
Serial.println("DualShock Controller Found");
break;
}
}
//My sabortooth motordriver can use the two signals 1000us-2000us to control the two motors
void loop()
{
ps2x.read_gamepad(false, 0);
Input1 = map(ps2x.Analog(PSS_LY), 0, 255, 2000, 1000);
Signal1.writeMicroseconds(Input1);
// Serial.print (Input1);
// Serial.print (",");
Input2 = map(ps2x.Analog(PSS_LX), 0, 255, 2000, 1000);
Signal2.writeMicroseconds(Input2);
//Serial.println (Input2);
delay(25);
}
The controller will not bind to the receiver without the 25 millisecond delay. The robot responds sluggishly compared to the response time of radio control system I previously used. Is this due to the delay? How can I eliminate this delay?
Thanks again for all the help and guidance