Hola. Como Estan?
Resulta que se me dio por hacer una alarma con arduino, y estaba probando el teclado matricial 4x4. Mi problema radica en que tengo 2 Char strings que son iguales pero en una sentencia if me devuelve el resultado en negativo. es decir No son iguales
Espero que me puedan ayudar...
Aqui esta la parte del codigo que falla:
void Activacion() { //Activacion normal
if (Queue == uPassword) {
//MatekTech ACTIVADA!
Serial.println("MatekTech ACTIVADA!");
}
}
Por si no entienden bien que es lo que pasa, No sale ningun error en consola, la sentencia if que falla tiene dos char string los cuales se comprueba si son iguales, Cuando yo digito en el teclado matricial la clave (Esta en el string uPassword) simplemente la sentencia da negativo como si no fueran iguales, incluso si manualmente en el codigo los hago iguales me sucede lo mismo.
y aqui todo el codigo...
//Teclado para alarma MatekTech M-CD 8 I2C (Teclado modelo MatekTech M-TI 8 I2C)
#include <Keypad.h>
int i = 0;
int e = 0;
int Counter = 0;
const byte nRows = 4; //four rows
const byte nCols = 4; //three columns
char key;
char keys[nRows][nCols] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[nRows] = {9, 8, 7, 6}; //connect to the row pinouts of the keypad
byte colPins[nCols] = {5, 4, 3, 2}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, nRows, nCols );
char dCausa[11] = "MOVIMIENTO";
char Queue[7] = {'0','0','0','0','0','0','\0'};
char Queue2[4] = {'0','0','0','\0'};
char mPassword[7] = {'A','D','C','8','9','1','\0'};
char pPassword[7] = {'1','2','3','4','5','6','\0'};
char uPassword[7] = {'0','1','2','3','4','5','\0'};
void setup(){
Serial.begin(9600);
}
void loop(){
key = keypad.getKey();
if (key != NO_KEY){
queue();
Counter = 0;
Serial.println(Queue);
Serial.println(Queue2);
}
Counter++;
if (Counter >= 10000) {
i = 0;
e = 0;
Counter = 0;
}
Activacion();
delay(1);
}
void queue() {
Queue[i] = key;
i++;
if (i == 6) {
i = 0;
}
Queue2[e] = key;
e++;
if (e == 3) {
e = 0;
}
}
void Activacion() { //Activacion normal
if (Queue == uPassword) {
//MatekTech ACTIVADA!
Serial.println("MatekTech ACTIVADA!");
}
}
void fActivacion() { //Ojo con esta funcion: ACTIVACION FORZADA
//MatekTech ACTIVADA!
Serial.println("Hola Instalador");
Serial.println("MatekTech ACTIVADA!");
}
void Disparo(){ //Disparo Normal
//MatekTech DISPARO!
Serial.println("DISPARO DE ALARMA");
}
void Desactivacion() { //Desactivacion Normal
//Hubo disparo de alarma! MatekTech Desactivada. Causa del disparo (VAR)
Serial.println("Hubo disparo de alarma!");
Serial.println("MatekTech Desactivada");
Serial.print("Causa del disparo ");
Serial.print(dCausa);
}
void fDesactivacion() { //Ojo con esta funcion: DESACTIVACION FORZADA
//DESACTIVACION FORZADA!
Serial.println("Hola Instalador");
Serial.println("MatekTech DESACTIVADA!");
}
Desde ya muchas gracias a quien pueda ayudarme...