se debe completar el código que falta de la función vertex2d para generar la figura

Dependencies:   mbed

main.cpp

Committer:
fabeltranm
Date:
2018-03-07
Revision:
2:878cb2697ab1
Parent:
1:370d6730c1cf

File content as of revision 2:878cb2697ab1:

#include "mbed.h"
#define MAXPOS 50       // en milimetros
#define SS_TIME 100     // en microsegundos

PwmOut myServoX(PB_3);
PwmOut myServoY(PB_4);


void draw()
{
    
    // ubicar  el codigo respectivo para  mover el eje z y dibujar 
    
}
void nodraw()
{
    
    // ubicar  el codigo respectivo para  mover el eje z y no dibujar 
    
}

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
    
    
    myServoX.pulsewidth_us(pulseX);
    myServoY.pulsewidth_us(pulseY);
    wait_ms(SS_TIME);

}


int main() {
     // configuracion de  periodo
    myServoX.period_ms(20);
    myServoY.period_ms(20);
    int posx=0;
    int posy=0;
    draw();
    while(1)
    {
        wait(2);
        vertex2d(posx,posy);
        posx+=10;
        if (posx>50){
            posx=0;
            nodraw();
        }
        posy=posy;
     }

}