Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 3:ed8f41c75a80
- Parent:
- 2:fda902bed8c6
- Child:
- 4:136a0aeb7d51
diff -r fda902bed8c6 -r ed8f41c75a80 main.cpp
--- a/main.cpp Fri Feb 22 13:28:24 2019 +0000
+++ b/main.cpp Fri Feb 22 18:30:06 2019 +0000
@@ -17,13 +17,14 @@
/*INGRESE L A CONFIGURACION DE LOS MOTORES*/
#define INITCMD 0xFF
-
+#define DEGREES_MAX 180
// definición de las variables globales
uint8_t N_motor; // almacena el número de motor
uint8_t N_grados; // almacena los grados que se mueve el motor
+// definición de las funciones
void setup_uart();
void setup_servo();
void mover_servo(uint8_t motor, uint8_t gradss);
@@ -58,15 +59,27 @@
}
+uint32_t degrees2usec(uint8_t grados){
+// Retorno el valor en usegundos, donde
+// y − y1 = m(x − x1 )
+ if(grados <= DEGREES_MAX)
+ return int(750+grados*1900/180);// u6
+ return 750;
+
+}
void mover_servo(uint8_t motor, uint8_t grados){
/*
-complementar el códogo necesarios
+complementar el códogo necesario
tip: deben pasar grados a microsegundo
+ se genera in ejemplo con un servo
*/
- uint32_t dpulse=0;
+ uint32_t dpulse=degrees2usec(grados);
+ //dpulse= degrees2sec(grados)
myservo1.pulsewidth_us(dpulse);
}
+
+