I am trying to code for a keypad and a beeper. I have used the code from various tutorials, and they all seem to work. However, I am getting the following error message:
too many initializers for 'char [3]'
I don't know what is causing this. Here is my code for anyone who wishes to help:
#include <Keypad.h>
int beeper = 4;
const byte ROWS = 4;
const byte COLS = 3;
char keys [ROWS] [COLS] = {
{"1", "2", "3"},
{"4", "5", "6"},
{"7", "8", "9"},
{"*", "0", "#"}
};
byte rowPins[ROWS] = {47, 45, 43, 41};
byte colPins[COLS] = {39, 37, 35};
Keypad keypad = keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
void setup(){
Serial.begin(9600);
pinMode(beeper, OUTPUT);
}
void loop(){
char key = keypad.getKey();
if(key){
Serial.println(key);
digitalWrite(beeper, HIGH);
delay(25);
digitalWrite(beeper, LOW);
}
}
If anyone can help then it would be much appreciated!