Created
June 6, 2019 01:50
-
-
Save HectorTorres/6d80efb03e0809de43899558303f7545 to your computer and use it in GitHub Desktop.
Arduino LabView Instrucciones
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*Declaracion de variables*/ | |
int ledPin = 13; // Pines de salida | |
int data_num; | |
/*Vector de 3 elmentos, posicion 0, posicion1 y posicion2*/ | |
char byteRead[20]; | |
/*Funcion SETUP se ejecuta una sóla vez*/ | |
void setup() | |
{ | |
Serial.begin(9600); // Configuracion de la velocidad serial | |
/*Configuracion de los pines de salida mediante un ciclo for*/ | |
pinMode(ledPin, OUTPUT); | |
/*Mensaje de Bienvenida en el puerto serial*/ | |
} | |
/*Funcion LOOP, se repite indefinidamente*/ | |
void loop() | |
{ | |
digitalWrite(ledPin, HIGH); | |
Serial.write("\nInicializando...\n");delay(10); | |
Serial.write("Ejercicio HeTPro para control de datos por serial\n");delay(10); | |
Serial.write("Particularmente con diferentes longitudes \n");delay(10); | |
Serial.write("Dispositivo: RSX2584\n");delay(10); | |
Serial.write("Nombre de usuario:\n");delay(10); | |
leer_comparar("Hector", "Usuario"); | |
Serial.write("Password:\n");delay(10); | |
leer_comparar("1234", "Password"); | |
Serial.write("Comando:\n");delay(100); | |
leer_comparar("MOV35M1", "Comando"); | |
Serial.write("Iniciando ciclo de depuracion del sistema.\n"); | |
Serial.write("Procesando"); | |
delay(100); | |
for(int i=0 ; i<=data_num ; i++ ){ | |
Serial.write("."); | |
delay(500); | |
} | |
Serial.write("\nTiempo de proceso: "); | |
Serial.print(millis()); | |
Serial.write("ms."); | |
while(1); | |
} | |
void leer_comparar(char byteRead_comp[20], char caso_lectura[20] ){ | |
while(Serial.available()==0);delay(10); | |
data_num=Serial.available(); | |
Serial.write("Caracteres leidos: "); Serial.println(data_num);delay(10); | |
for(int i=0 ; i<data_num ; i++ ){ | |
byteRead[i] = Serial.read();Serial.write("."); | |
} | |
delay(10); | |
Serial.write(byteRead_comp); | |
if (strcmp(byteRead_comp, byteRead) == 0){ | |
Serial.print("\n"); | |
Serial.write(caso_lectura); | |
Serial.print(": "); | |
Serial.write(byteRead_comp); | |
Serial.print("\n"); | |
} | |
else{ | |
Serial.println("\r\nVALOR NO VALIDO REINICIE EL DISPOSITIVO"); | |
while(1); | |
} | |
memset(byteRead,0,20); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment