Contributing libraries

Hi,

I have built a library for the Arduino to interface Playstation2 controllers.
As I am new to C/C++, my writing and documentation may look a bit goofy to the eyes of experts. However, I think it's usage fairly follows the style of other Arduino libraries and is certainly practical.

I would appreciate advise on where I should be informing about this piece of code in order to have it listed among the "Contributed Libraries" on this site, along with advise on what it lacks in case it does not qualify.

It is stored at the URL below.
Reference and directions on basic wiring are included in the .txt file.
http://pspunch.com/pd/files/library/GPSX.zip

Thanks.

It would be great if you also put the documentation and a download link on a webpage, possibly the Arduino playground. Then just post again, and I should link it.

Hi mellis,

Sorry for the delay in response.
I have taken your advise and prepared an introduction page on my web site over the weekend.
Is it possible for you to link directly to the following URLs?

I have two libraries now.

  • PS2 controller interface.
    Brief article and copy of attached documentation.
    Compared to the other PSX library currently on the Wiki, this one is short in some parts, but has some additional features.
    Studio Gyokimae - Arduino PS2 controller interface

  • MIDI IN library
    Copy of attached documentation only.
    This is a framework to ease processing of incoming MIDI messages by setting your own callbacks depending on the event.
    Studio Gyokimae

I am relatively new to this community and not too aware of its hierarchy yet.
Please point out if I am rudely asking to bypass any conventional procedures.

Thanks.

I've been trying to use your library to use a PS2 controller to control some servos.

The buttons seem to work OK, but I can't get the analog sticks to function. There is no analog stick usage in the example sketch - could you put one up here, or msg me please?

I've been doing something along the lines of

byte b = ANALOG_RIGHT_X(PSX_PAD1);

But the value of b is always the maximum value (255). I'm quite sure the analog sticks on the controller work correctly. Has anyone else got this working?

For some reasons the analog light on the controller is not turned on either. If I press the analog button, the light flashes on briefly.

Any ideas?

Absolutely typical... I wrote that post, then decided to try again... and of course, it works! Guess I must have had a loose connection somewhere...

Thanks for the library! Keep up the good work :smiley:

EDIT

Actually there is a problem.

I can use the analogs (both of them) and get sane results. I can then map these values to 0-180 degrees for use with a servo. However, if I try to write the servo inside the loop() function, everything falls apart.

If I try to turn on the analog it flashes briefly on, then turns off (the red light, that is). Even without the servo, the controller starts up in digital mode (despite being set up to start in analog mode), but I can press the analog button and put it into analog mode.

So it seems the servo write is messing things up - any ideas why? Something to do with timers or some such?

Code is below:

#include <math.h>
#include <GPSXClass.h>
#include <Servo.h>
#include <WProgram.h>

Servo s1;

void setup()
{
  Serial.begin(9600);
  s1.attach(9);
  s1.write(90);
  
 PSX.mode(PSX_PAD1, MODE_ANALOG, MODE_LOCK);
  
  // Poll current state once.
  PSX.updateState(PSX_PAD1);
}

void loop()
{
  PSX.updateState(PSX_PAD1);

  // THIS WORKS
  byte b = ANALOG_LEFT_Y(PSX_PAD1);
  
  // THIS WORKS TOO
  b = map(b, 0, 255, 0, 178);
  
  // WITHOUT THIS, VALUES FOR b READ OVER SERIAL ARE FINE
  // WITH IT, NOTHING WORKS!
  s1.write(b);
  
  Serial.println(b, DEC);
  
}

EDIT 2

Needed a separate power supply for the servos... sorted now. And learned the lesson that servos don't like having their polarity reversed... oops. Ah well, won't be making that mistake again!

T

Hi Thom,

It's a great pleasure to hear of someone making use of it.
I hope all was fine at the end of the day. :slight_smile: