accelerometer as potentiometer

I have a Mx2125 accelerometer hooked up to my Arduino and am trying to use it in place of the potentiometers on my Cellular Automaton video synth.

I have the accelerometer reading just fine and mapped it to read 0-255.

I have connected the center pin that would normally go to the center pin on the potentiometer to the 9 and 10PWM pins on the Arduino. Below is my code, if anyone have any tips or ideas I would be very happy:

int xpin = 2;
int ypin = 3;

// Digital pin settings
int xOut = 9; // LEDs connected to digital pins 9, 10 and 11
int yOut = 10; // (Connect cathodes to digital ground)

int xVal = 0; // Variables to store the input from the potentiometers
int yVal = 0;

void setup()
{
pinMode(xOut, OUTPUT); // sets the digital pins as output
pinMode(yOut, OUTPUT);

Serial.begin(9600);
pinMode(xpin, INPUT);
pinMode(ypin, INPUT);
}

void loop()
{
int pulseX, pulseY;
int accX, accY;

// read pulse from x- and y-axes
pulseX = pulseIn(xpin,HIGH);
pulseY = pulseIn(ypin,HIGH);

// convert the pulse width into acceleration
// accX and accY are in milli-g's: earth's gravity is 1000.

accX = map(pulseX, 3700, 6150, 0, 255);
accY = map(pulseY, 3700, 6150, 0, 255);

analogWrite(xOut, xVal); // Send new values to LEDs
analogWrite(yOut, yVal);

// print the acceleration
Serial.print(accX);
Serial.print(" ");
Serial.print(accY);
Serial.println(" ");

delay(10);
}

thanks.

You haven actually said what is wrong.

I assume there is no response. If this is so check that the accelerometer is working by simply getting a sketch to read the value and print it out. Then you can see if your input is correct.

No, it is printing and reads just fine in the serial monitor.

The input is not the problem I seem to be having trouble with the output, It does not seem to be responding, and I am not sure if it is a code issue or a wiring issue, I am leaning toward code.

accX = map(pulseX, 3700, 6150, 0, 255);
 accY = map(pulseY, 3700, 6150, 0, 255);
 
 analogWrite(xOut, xVal);    // Send new values to LEDs
 analogWrite(yOut, yVal);

Should this not be:-

accX = map(pulseX, 3700, 6150, 0, 255);
accY = map(pulseY, 3700, 6150, 0, 255);

analogWrite(xOut, accX ); // Send new values to LEDs
analogWrite(yOut, accY );