Continuous Rotation Servos a Valiant attempt at PS2 Communication

Hello all,

I am implementing a (hacked 180 servo) continuous rotation servo in my project and controlling it with a PS2 controller (link to the library). I am using an Arduino Duemanilove, and have found that, after super gluing the potentiometer inside the servo, the zero point is “1273 microseconds”. I have tried and tried to control this servo with my PS2 controller, but to no avail. I have followed closely the examples of other people implementing this library in a very similar fashion, and have even used their code on my board successfully. For some reason, this continuous rotation servo does not cooperate. Here is the code I currently have on the board:

#include <PS2X_lib.h>
#include <Servo.h>
Servo s;
PS2X p;

//PS2 pins
#define DAT 6
#define CMD 7
#define ATT 8
#define CLK 9

void setup() {
  s.writeMicroseconds(1273);
  s.attach(2);
}

void loop() {
  
  if(p.ButtonPressed(PSB_PAD_LEFT)) {
    s.writeMicroseconds(1400);
  }
  else if(p.ButtonPressed(PSB_PAD_RIGHT)) {
    s.writeMicroseconds(1150);
  }
  else {
    s.writeMicroseconds(1273);
  }
}

Can someone please explain how to use this PS2 library properly?

Thank you,
the_roboticist

Can someone please explain how to use this PS2 library properly?

Do you KNOW that the PS2 is connected correctly? Do you KNOW that the Arduino is reading the state of the switches correctly? There is nothing in your code that illustrates that you do know either thing.

So, why are you trying to use the data to control a servo?