I am new to arduino. Recently I tried the Arduino Duemilanove, which was the basic board. I connected a accelerometer to the analog input and PWM was successfully generated. The servo did move accordingly, however I realise that [glow]there's some noise either internal or external, that makes the servo jerk[/glow] when the accelerometer is in rest, any good way to recommend me in [glow]removing/filtering the noise[/glow]?

50Hz yes, PWM no; well, not exactly.The rate and duty cycles you mention will work, but the standard PWM pins don't run at 50Hz, more like 4 or 500Hz, which a standard R/C servo won't like.Strictly speaking, R/C servos use Pulse Position Modulation (PPM), not Pulse Width Modulation (PWM).The distinction is a fine one.

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.Do not send technical questions via personal messaging - they will be ignored.

void setup(){ // initialize the pushbutton pin as an input: pinMode(buttonPin, INPUT); //rudder.attach(12); // attaches the servo on pin 9 to the servo object aileron.attach(11); // attaches the servo on pin 9 to the servo object pitch.attach(10); // attaches the servo on pin 9 to the servo object}

void loop() { buttonState = digitalRead(buttonPin); if(buttonState == HIGH){ x_val = analogRead(x_pot); // reads the value of the potentiometer (value between 0 and 1023) y_val = analogRead(y_pot); // reads the value of the potentiometer (value between 0 and 1023) x_val = map(x_val, 350,500 , 0, 179); // scale it to use it with the servo (value between 0 and 180) y_val = map(y_val, 350, 500, 0, 179); // scale it to use it with the servo (value between 0 and 180) } else if(buttonState == LOW) { x_val = analogRead(x_joy); // reads the value of the potentiometer (value between 0 and 1023) y_val = analogRead(y_joy); // reads the value of the potentiometer (value between 0 and 1023) x_val = map(x_val, 30,140 , 0, 179); // scale it to use it with the servo (value between 0 and 180) y_val = map(y_val, 30, 140, 0, 179); // scale it to use it with the servo (value between 0 and 180) } //x_val = map(x_val, 30,60 , 0, 179); // scale it to use it with the servo (value between 0 and 180) aileron.write(x_val); // sets the servo position according to the scaled value //aileron_right.write(x_val); // sets the servo position according to the scaled value // waits for the servo to get there

// y_val = map(y_val, 30, 70, 0, 179); // scale it to use it with the servo (value between 0 and 180) pitch.write(y_val); // sets the servo position according to the scaled value //delay(15); // waits for the servo to get there

/* x_val = analogRead(z_pot); // reads the value of the potentiometer (value between 0 and 1023) z_val = map(z_val, 300, 800, 0, 179); // scale it to use it with the servo (value between 0 and 180) rudder.write(z_val); // sets the servo position according to the scaled value */

// delay_val = analogRead(delay_pot); // reads the value of the potentiometer (value between 0 and 1023) // delay_display = map(delay_pot, 0, 1023, 0 ,100); // scale it to use it with the servo (value between 0 and 180)

But I think I know what is the problem that cause the "noise". Basically I'm using a accelerometer to control the servo, the output of the accelerometer is not constant (eg. 350, 354, 348), and this might be the reason that cause the servo to be shaky. Do you have any way to make average out the accelerometer signal or PWM output to make it a constant (eg. [350 + 354 + 348] / 3 = 350.67) ?

I have an accelerometer that runs on 3.3v. The voltage regulator I was using was generating a very small amount of noise. So small that I needed to use an oscilloscope to see it. But the noise in the power supply was causing noticable noise in the reading from the accelerometer. flitering the power with a capacitor fixed the issue