Frank Girald
/
Servo
Servo Motor
Fork of Servo_HelloWorld by
Revision 2:115ddb84b970, committed 2017-10-26
- Comitter:
- franni
- Date:
- Thu Oct 26 13:46:52 2017 +0000
- Parent:
- 1:40d2fd0b99e6
- Commit message:
- Servomotor
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 |
--- a/main.cpp Tue Nov 23 16:10:35 2010 +0000 +++ b/main.cpp Thu Oct 26 13:46:52 2017 +0000 @@ -1,13 +1,21 @@ -// Hello World to sweep a servo through its full range - #include "mbed.h" #include "Servo.h" -Servo myservo(p21); +Serial rs232(USBTX, USBRX); +Servo servomotor(PTE29); // PIN PWM +int grados,k; -int main() { - for(float p=0; p<1.0; p += 0.1) { - myservo = p; - wait(0.2); +int main() +{ + rs232.baud(9600); + while(1) { + grados=0;k=0; + for(float i=0; i<1.0; i += 0.08333) { // 12 pasos de 15° (0 a 180° entre 0 y 1.0 mseg: 0.08333mseg por paso) + servomotor = i; + wait(0.5); + grados=k*15; + rs232.printf("%d \r\n",grados); //Visualiza avance cada 15° + ++k; + } } }
--- a/mbed.bld Tue Nov 23 16:10:35 2010 +0000 +++ b/mbed.bld Thu Oct 26 13:46:52 2017 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/e2ac27c8e93e +https://mbed.org/users/mbed_official/code/mbed/builds/97feb9bacc10 \ No newline at end of file