im trying to make it so multiple keypresses will activate a light but the char arrays seem like they skipped the if commands and the arrays are already set to their numbers because the green light is all ways on. is there any way to make the chars not skip the if command and set their numbers when the key is pressed i believe that's what it is
here's the code that i have
#include <Keypad.h>
#include <Wire.h>
#include <SoftwareSerial.h>
#include <Servo.h>
int red=11;
int green=10;
int incomingByte = 0;
const byte ROWS = 4; //four rows
const byte COLS = 3; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};
byte rowPins[ROWS] = {5, 6, 7, 8}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {2, 3, 4}; //connect to the column pinouts of the keypad
//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
void setup(){
Serial.begin(9600);
analogWrite(red,255);
}
void loop(){
char Key = customKeypad.getKey();
if (Key == '1'){
Serial.println("W");
char key1 = '1';
Serial.println(key1);
}
if (Key == '2'){
Serial.println("i");
char key2 = '2';
Serial.println(key2);
}
if (Key == '3'){
Serial.println("n");
char key3 = '3';
Serial.println(key3);
char array4[3] = { 'key1', 'key2','key3' };
Serial.println (array4);
}
if (array4, 123){
analogWrite(green,255);
}
if (Key == '#'){
Serial.println("LOSE");
analogWrite(red,255);
digitalWrite(green,LOW);
}
}