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.
Fork of 01-01SolucionFuncionXY by
Diff: main.cpp
- Revision:
- 3:fe8e265eaf6e
- Parent:
- 2:878cb2697ab1
- Child:
- 4:29a8b1df7fe2
--- a/main.cpp Wed Mar 07 00:03:12 2018 +0000
+++ b/main.cpp Wed Mar 07 00:10:11 2018 +0000
@@ -1,34 +1,35 @@
#include "mbed.h"
#define MAXPOS 50 // en milimetros
#define SS_TIME 100 // en microsegundos
+#define POSDRAW 10
PwmOut myServoX(PB_3);
PwmOut myServoY(PB_4);
+PwmOut myServoZ(PB_5);
+int coord2us(float coord)
+{
+ if(0 <= coord <= MAXPOS)
+ return int(750+coord*1900/50);// u6
+ return 750;
+
+}
+
void draw()
{
-
- // ubicar el codigo respectivo para mover el eje z y dibujar
-
+myServoZ.pulsewidth_us(POSDRAW);
+wait(1);
}
void nodraw()
{
-
- // ubicar el codigo respectivo para mover el eje z y no dibujar
-
+myServoZ.pulsewidth_us(MAXPOS);
+wait(1);
}
-
void vertex2d(float x, float y){
- int pulseX ;
- int pulseY ;
-
- // UBICAR EL CODIGO QUE HACE FALTA
- // la funciòn como parametros tiene las coordenadas x y y en milimetros y
- // debe calcular las variables pulseX y pulseY para dar paso a la actualizaciòn
- // de la posiciòn de los dos servomotores
-
+ int pulseX = coord2us(x);
+ int pulseY = coord2us(y);
myServoX.pulsewidth_us(pulseX);
myServoY.pulsewidth_us(pulseY);
@@ -37,6 +38,7 @@
}
+
int main() {
// configuracion de periodo
myServoX.period_ms(20);
