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.
6 years ago.
How to stop Servor motor using pushbutton
- include "mbed.h" DigitalIn pb2(D14); PwmOut servo_motor(PTD1); KL25Z pinout
int main() {
while(true) { if (pb2 == true) { servo_motor.period_ms(20); while(1){ servo_motor.pulsewidth_us(600); wait(3); servo_motor.pulsewidth_us(2000); wait(3); } } else {
servo_motor.period_ms(1);
}
} }