
f
main.cpp
- Committer:
- aldomarez
- Date:
- 2018-10-29
- Revision:
- 0:8e645bca6afc
File content as of revision 0:8e645bca6afc:
#include "mbed.h" //Program to 'sweep' test a 'standard RC type servo //Define some parameters using compiler directive '#define' //Check Servo DATA if 0.75ms to 2.25ms then use min=750 and max=2250 //NB be values in microseconds (Following are generic values) #define MID 1500 #define MIN 1000 #define MAX 2000 #define STEP 50 #define TIME 100 PwmOut myServo(D5); InterruptIn Incrementa(USER_BUTTON); InterruptIn Decrementa(D15); void dispara1() { for (int i=MIN;i<=MAX;i+=STEP){ myServo.pulsewidth_us(i); wait_ms(TIME); } } void dispara2() { for (int i=MAX;i>=MIN;i-=STEP){ myServo.pulsewidth_us(i); wait_ms(TIME); } } int main() { myServo.period_ms(20); while(true) { Decrementa.fall(&dispara1); Incrementa.fall(&dispara2); } }