este programa enciende o apaga algo si se dice encender o se dice apagar al reconocedor de voz del dispositivo android
correccion!!! se dice ENCIENDE y se dice APAGA
este es el archivo .apk de android APP INVENTOR
/media/uploads/tony63/voz7.apk
main.cpp
- Committer:
- tony63
- Date:
- 2015-10-05
- Revision:
- 1:dff328579a1e
- Parent:
- 0:a1a849fc3044
File content as of revision 1:dff328579a1e:
//PROGRAMA PARA RECIBIR CARACTERES DESDE EL PC Y ACTIVAR LEDS //UTIL EN LECTURA DE CADENAS PARA APP INVENTOR (reconocimiento de voz con app inventor) #include "mbed.h" #include "stdio.h" #include "string.h" DigitalOut LedVerde(LED2); DigitalOut LedRojo(LED1); DigitalOut LedAzul(LED3); Serial usart(PTE0,PTE1); //puertos del FRDM para el modem Serial pc(USBTX,USBRX); //puertos del PC char buffer[4];// TAMAÑO DEL BUFER Timer t; //VALOR DEL TIEMPO int count; int contador1; int contador2; int i = 0; int c=0; char r[]=""; char clave1[]="on"; char clave2[]="of"; int readBuffer(char *buffer,int count) //esta funcion lee un bufer de datos { int i=0; t.start(); //CUENTA EL TIEMPO DE CONEXION E INICIA while(1) { while (usart.readable()) { char c = usart.getc(); if (c == '\r' || c == '\n') c = '$';//si se envia fin de linea o de caracxter inserta $ buffer[i++] = c;//mete al bufer el caracter leido if(i > count)break;//sale del loop si ya detecto terminacion } if(i > count)break; if(t.read() > 1) { //MAS DE UN SEGUNDO DE ESPERA SE SALE Y REINICA EL RELOJ Y SE SALE t.stop(); t.reset(); break; } } return 0; } void cleanBuffer(char *buffer, int count) //esta funcion limpia el bufer { for(int i=0; i < count; i++) { buffer[i] = '\0'; } } int main(void) { LedVerde=1; LedRojo=1; LedAzul=1; LedVerde=1; usart.baud(9600); usart.format(8,Serial::None,1); while(1){ if (usart.readable()) { readBuffer(buffer,3); pc.printf("buffer= %s\n\r ",buffer); //imprime el bufer for(int i=0; i < 2; i++) { if (clave1[i] == buffer[i]){ contador1++; if (contador1==2){ LedAzul=0; contador1=0; break;} } } } for(int i=0; i < 2; i++) { if (clave2[i] == buffer[i]){ contador2++; if (contador2==2){ LedAzul=1; contador2=0; break; } } } cleanBuffer(buffer,2); } }