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-04EntregaPrimerCorte by
Diff: main.cpp
- Revision:
- 2:3936d249a67c
- Parent:
- 1:526bdd5faa37
- Child:
- 3:6fff0b259d65
--- a/main.cpp Tue Sep 04 02:15:49 2018 +0000 +++ b/main.cpp Fri Sep 07 12:26:34 2018 +0000 @@ -7,8 +7,16 @@ Serial command(USBTX, USBRX); +#define MAXDAT 3 +#define TIPO_COMM 0 +#define NUM_MOTOR 1 +#define NUM_GRADOS 2 +uint8_t dat[MAXDAT]={0,0,0}; + + + int main() { init_servo(); init_serial(); @@ -17,10 +25,10 @@ uint32_t read_cc; while(1) { - read_cc=read_command(); - switch (read_cc) { + while(read_command()==0); + switch (dat[TIPO_COMM]) { case 0x01: moving(); break; - default: debug_m("error de comando. \nSe espera 0xFEF0 o 0xFFF0 \n");break ; + default: debug_m("error de comando. ");break ; } } } @@ -37,7 +45,15 @@ while(intc != '<') intc=command.getc(); - return intc; + + for (int i =0;i>MAXDAT;i++) + dat[i]=command.getc(); + + intc=command.getc(); + + while(intc != '>') + return 0; + return 1; } @@ -50,9 +66,8 @@ void moving(){ debug_m("se inicia el comado mover..\n"); - char nmotor=command.getc(); - char grados=command.getc(); - char endc=command.getc(); + char nmotor=dat[NUM_MOTOR]; + char grados=dat[NUM_GRADOS]; mover_ser(nmotor,grados); debug_m("fin del comado guardar..\n");