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
main.cpp
00001 #include "mbed.h" 00002 #include "main.h" 00003 00004 Serial command(USBTX, USBRX); // leer comnunicacion serial 00005 00006 int main() { 00007 init_servo(); // inicializar servo 00008 init_serial(); //inicializar periodo de servos 00009 00010 debug_m("inicio \n"); 00011 uint32_t read_cc; // definimos los 4 numeros hexadecimales enviados 00012 while(1) 00013 { 00014 read_cc=read_command(); // leemos los 4 numeros hexadecimales enviados 00015 switch (read_cc) { 00016 case 0x01: moving(); break; 00017 //default: debug_m("error de comando. \nSe espera 0xFEF0 o 0xFFF0 \n");break ; 00018 } 00019 } 00020 } 00021 00022 00023 00024 uint32_t read_command() 00025 { 00026 // retorna los byte recibidos concatenados en un entero, 00027 00028 char intc=command.getc(); 00029 while(intc != 0x000000ff) // despues de leer 0xff lee los 4 datos 00030 intc=command.getc(); 00031 return command.getc(); 00032 } 00033 00034 00035 void init_serial() 00036 { 00037 command.baud(9600); // leer en el monitor serial 00038 } 00039 00040 00041 void moving(){ 00042 debug_m("se inicia el comado mover..\n"); 00043 00044 char nmotor=command.getc(); // se asigna el 2 valor hexadecimal al numero de servo 00045 char grados=command.getc(); // se asigna el 3 valor hexadecimal al numero de grados 00046 char endc=command.getc(); // se asigna el 4 valor hexadecimal para terminar de leer la comunicacion 00047 mover_ser(nmotor,grados); // llama el void mara mover servo con grados 00048 debug_m("fin del comado guardar..\n"); 00049 00050 } 00051 00052 void debug_m(char *s , ... ){ 00053 #if DEBUG 00054 command.printf(s); // imprime en el monitor serial 00055 #endif 00056 }
Generated on Wed Jul 20 2022 02:05:06 by
1.7.2
