
f
Revision 0:8e645bca6afc, committed 2018-10-29
- Comitter:
- aldomarez
- Date:
- Mon Oct 29 18:33:36 2018 +0000
- Commit message:
- ll; ;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Oct 29 18:33:36 2018 +0000 @@ -0,0 +1,33 @@ +#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); + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Oct 29 18:33:36 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/a7c7b631e539 \ No newline at end of file