7 years ago.

Problem in running Servo with LPC11U24.... i used the following code with adxl345 as analog inputs

#include "mbed.h"
AnalogIn xvalue(p19);
AnalogIn yvalue(p20);
PwmOut servoa(p25);
PwmOut servob(p26);
int main()
{ 
servoa.period(.02);
servob.period(.02);
while(1)
{servoa.pulsewidth(.001+.0001*xvalue);
wait(.3);
servob.pulsewidth(.001+.0001*yvalue);
wait(.3);
}
}

I thank Mr. Erik Olieman for his suggedtions.I wanted to interface an accelerometeradxl345 with the lpc11u24 to control servo. Can you tell me if the above code might work.

1 Answer

7 years ago.

Use <<code>> and <</code>>, this is pretty close to unreadable. Then it is nice if you actually add what is going wrong. Also if something doesn't work, remove everything that isn't required, like the AnalogIn here.

If you see http://mbed.org/handbook/PwmOut, then p21 and p22 aren't valid PwmOut. Finally, due to how the PWM is set only those belonging to CT32B0 can be used for PWM, the others can't reach the required period of 0.02. However if you use http://mbed.org/users/Sissors/code/FastPWM/. For your requirements that should just be a dropin replacement for PwmOut, and then you can use all pins listed on the handbook page to control servos, also the CT16 ones.

Accepted Answer