Accelerometer code

Hey guys, 

looking to control two servos (standard futuba hobby servos) from a adxl 335.

I have all the mechanical and electrical systems ready im just trying to figure out the code.

I have seen how to use the accelerometer to measure acc and just print to the serial on my pc, but how do i get those signals to control the position of a servo.

Also, how would you go about adding the signals from two axis (ie sum up the values from the x axis and y axis, and have a servo respond to that new number)

I have also been having problems when trying to power the servos from an external source (other then the 5v and grd on the arduino, i am using a hobby battery and a 5V reg, but for some reason the servos stop responding to the code when powered this way.

thanks for the help

Are you

Sharing grounds with the power supplies? 

As for the code, never used it, you could try

 

map(val, minimum adxl value, maximum adxl value, 0(for servos), 180(for servos));

myservo.Write(val);