7 years ago.

Servocontrol with LPC11u24 using accelerometer iusedfollowingcode

#include "mbed.h"
AnalogIn xvalue(p19);
AnalogIn yvalue(p20);
DigitalOut servoa(p25);
DigitalOut servob(p26);
int main()
{ 

while(1)
{servoa=1;servob=1);
wait(.0005+.00002*xvalue.read());
servoa=0;
wait(.02);

}
}

I wanted to know if the code is correct. Can you guys also tell me what would be the range of values for analog in

1 Answer

7 years ago.

You now use DigitalOut for servos, you need PwmOut.

AnalogIn returns values between 0 and 1.