Software that allows basic remote control of the position of a servo (schematic included in the comments)
Fork of Nucleo_sg90_remote_control by
main.cpp
- Committer:
- YPROY
- Date:
- 2017-01-30
- Revision:
- 0:7a91558f8c41
- Child:
- 1:df2cee74ab8b
File content as of revision 0:7a91558f8c41:
#include "mbed.h" PwmOut mypwm(PA_7); InterruptIn monBouton(USER_BUTTON); int compteur; int cycle[]={700, 1550, 2500, 1550}; void pressed(void) { compteur++; if (compteur >= sizeof(cycle)/sizeof(int)) { compteur = 0; } mypwm.pulsewidth_us(cycle[compteur]); } DigitalOut myled(LED1); int main() { compteur = 0; mypwm.period_ms(20); mypwm.pulsewidth_us(500); // printf("pwm set to %.2f %%\n", mypwm.read() * 100); monBouton.fall(&pressed); while(1) { myled = !myled; wait(1); } }