#include <Keypad.h>
#include <IRremote.h>
const int ROW_NUM = 4; //four rows
const int COLUMN_NUM = 4; //four columns
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
IRsend irsend;
int A[] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
int B[] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
int C[] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
int D[] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
char keys[ROW_NUM][COLUMN_NUM] = {
{'1','2','3', 'A'},
{'4','5','6', 'B'},
{'7','8','9', 'C'},
{'*','0','#', 'D'}
};
byte pin_rows[ROW_NUM] = {2, 3, 4, 5}; //connect to the row pinouts of the keypad
byte pin_column[COLUMN_NUM] = {6, 7, 8, 9}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), pin_rows, pin_column, ROW_NUM, COLUMN_NUM );
void setup(){
Serial.begin(9600);
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void loop(){
char key = keypad.getKey();
if (key == "#"){
irsend.sendRC5(0x0, 8); //send 0x0 code (8 bits)
delay(200);
irsend.sendRC5(0x1, 8);
delay(200);
**char array_choice = keypad.getKey();** // The source of my misery
if (array_choice == A) {
int index_of_signal = keypad.getKey();
if (index_of_signal == 0) {
irsend.sendRC5(array_choice[index_of_signal], 8);
}
if (index_of_signal == 1) {
irsend.sendRC5(array_choice[index_of_signal], 8);
}
if (index_of_signal == 2) {
irsend.sendRC5(array_choice[index_of_signal], 8);
}
if (index_of_signal == 3) {
irsend.sendRC5(array_choice[index_of_signal], 8);
}
if (index_of_signal == 4) {
irsend.sendRC5(array_choice[index_of_signal], 8);
}
if (index_of_signal == 5) {
irsend.sendRC5(array_choice[index_of_signal], 8);
}
if (index_of_signal == 6) {
irsend.sendRC5(array_choice[index_of_signal], 8);
}
if (index_of_signal == 7) {
irsend.sendRC5(array_choice[index_of_signal], 8);
}
if (index_of_signal == 8) {
irsend.sendRC5(array_choice[index_of_signal], 8);
}
if (index_of_signal == 9) {
irsend.sendRC5(array_choice[index_of_signal], 8);
}
}
if (array_choice == B) {
int index_of_signal = keypad.getKey();
if (index_of_signal == 0) {
irsend.sendRC5(array_choice[index_of_signal], 8);
}
if (index_of_signal == 1) {
irsend.sendRC5(array_choice[index_of_signal], 8);
}
if (index_of_signal == 2) {
irsend.sendRC5(array_choice[index_of_signal], 8);
}
if (index_of_signal == 3) {
irsend.sendRC5(array_choice[index_of_signal], 8);
}
if (index_of_signal == 4) {
irsend.sendRC5(array_choice[index_of_signal], 8);
}
if (index_of_signal == 5) {
irsend.sendRC5(array_choice[index_of_signal], 8);
}
if (index_of_signal == 6) {
irsend.sendRC5(array_choice[index_of_signal], 8);
}
if (index_of_signal == 7) {
irsend.sendRC5(array_choice[index_of_signal], 8);
}
if (index_of_signal == 8) {
irsend.sendRC5(array_choice[index_of_signal], 8);
}
if (index_of_signal == 9) {
irsend.sendRC5(array_choice[index_of_signal], 8);
}
}
}
if (key == "*") {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
irrecv.resume();
}
}
}
This code is for a universal IR remote, it's supposed to get the value of the IR signal in the selected array and transmit the signal.
Yet when I try to get the keypad input to select the array the user would like to use, I get the error mentioned in the title. I know that my mistake is that the keypad is storing the selection as a char, because of that, it is unable to recognise that the input is supposed to select a specific array and access it.
How would I go about fixing this problem? Any help would be appreciated.