codigo de programacion de comunicacion serian envio de char para dibujar linea diagonal desde 0,0 a 50,50 y cuadrado 30x30 iniciando en 10x10

Dependencies:   mbed

  1. include "mbed.h" punto min 500 punto max 2400
  2. define MAXPOS 50 en milimetros
  3. define SS_TIME 100 en microsegundos PwmOut myServoZ(PB_3); eje_Z PwmOut myServoX(PB_4); eje_X PwmOut myServoY(PB_10); eje_Y Serial command(USBTX, USBRX,9600);

void NoDraw(){ int pulseZ ; pulseZ=((1*35)+500); myServoZ.pulsewidth_us(pulseZ); wait_ms(SS_TIME);}

void Draw(){ int pulseZ ; pulseZ=((35*35)+500); myServoZ.pulsewidth_us(pulseZ); wait_ms(SS_TIME);}

void vertex2d(float x, float y){ int pulseX ; int pulseY ; pulseX=((x*35)+500); pulseY=((y*35)+500); myServoX.pulsewidth_us(pulseX); myServoY.pulsewidth_us(pulseY); wait_ms(SS_TIME);}

void Home(){ wait(1); vertex2d(0,0); }

int main() { myServoX.period_ms(20); myServoY.period_ms(20); myServoZ.period_ms(20); int posx=0; int posy=0; int ZZ=0; char Comunicacion; command.printf("hi"); Comunicacion= command.getc();

while(ZZ==0){ if(Comunicacion=='d'){ wait(1); Draw(); vertex2d(posx,posy); posx+=10; posy+=10; if (posx>50){ posx=0;} if (posy>50){ posy=0; wait(1); ZZ=1;} } if(Comunicacion=='c'){ wait(1); vertex2d(posx,posy); posx+=10; posy+=10; if (posx>50){ posx=0;} if (posy>50){ posy=0; wait(1); ZZ=1;} } if(Comunicacion=='f'){ wait(1); Draw(); vertex2d(0,0); wait(1); vertex2d(10,10); wait(1); vertex2d(10,40); wait(1); vertex2d(40,40); wait(1); vertex2d(40,10); wait(1); vertex2d(10,10); wait(1); ZZ=1; } if(Comunicacion=='v'){ wait(1); vertex2d(0,0); wait(1); vertex2d(10,10); wait(1); vertex2d(10,40); wait(1); vertex2d(40,40); wait(1); vertex2d(40,10); wait(1); vertex2d(10,10); wait(1); ZZ=1; }}

while(ZZ==1){ NoDraw(); Home();} } wait(1); } }

Download repository: zip gz

Files at revision 0:0d79995e1043

Name Size Actions
[up]
main.cpp 2389 Revisions Annotate
mbed.bld 69 Revisions Annotate