Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
7 years, 10 months ago.
How to control with multiple servos with LPC1768
How to control with multiple servos with LPC1768 I tried with below code and its not working,
- include "mbed.h"
PwmOut PWM1(p21); create a PWM output called PWM1 on pin 21 PwmOut PWM2(p22); create a PWM output called PWM1 on pin 21
float i; float j;
int main() { PWM1.period(0.02); set PWM period to 10 ms PWM2.period(0.02); set PWM period to 10 ms
while(1) { while(i<0.12) { PWM1=i; wait(0.01); i=i+0.001;
} while(i>0.02) { PWM1=i; wait(0.01); i=i-0.001;
}
while(j<0.12) { PWM2=j; wait(0.01); j=j+0.001;
} while(j>0.02) { PWM2=j; wait(0.01); j=j-0.001;
}
} }