adxl335 to control servo help with map

I must say that I'm surprised, or that you have a different definition of working than I do.

This code is reading the value of a potentiometer, not an accelerometer. If the potentiometer is wired correctly, this code should result in analogRead returning values in the range 0 to 1023.

I don't think you completely get what I'm doing still. This sketch is from the arduino programmer as a demo, potentiometer or accelerometer it's still analog, I just didn't bother to rename the code till I finish my initial testing. All I have to do is connect the x-axis of the accelerometer to that same pin and it will read the values.

I also used that adxl335 code to get the values with serial print which allows me to see what value range I'm using. At steady state ( leaving the accelerometer flat on the table) I get 336, tilt it on one side on an angle and right side on the same angle I get around 269 to 409 which is the range I'm planning to use. I map that to 0-179 which is mainly the range of my servo. Now if I power it up not touching the accelerometer the servo is roughly at 90 degrees.

I tilt it one way, it will rotate the servo towards min or high depending on which way I tilt the accelerometer.

Well it's working to my standards because I know exactly what I'm trying to do and it did what I wanted to.

I have 2 servo's x and y axis being controlled by the accelerometer now, just working on smoothing the movement by taking averages.

For values from 0 to 269, this will result in val containing a negative value. For values from 410 to 1023, val will contain values of 180 or more.

So, for a broad range of potentiometer movement, the map function will output a value that the servo can not move to. Unless it's not a normal 180 degree servo.

Why would the pot or aka (accelerometer) output values higher than 409? I mapped the min to high values between 269 and 409. Which is the values that I tested and will never go past.