-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Closed
Description
Hello,
I want to use my ESP8266 12E with a keypad, I wired it this way:
1-----D0
2-----Rx
3-----SD3
4-----D3
5-----D4
6-----D5
7-----D6
8-----D7
I didn't use the D1 and D2 because I want to add an LCD I2C later.
Well, first I tried this code, same wiring it works perfectly:
#include <Keypad.h>
const byte n_rows = 4;
const byte n_cols = 4;
char keys[n_rows][n_cols] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte colPins[n_rows] = {D3, 10, 03, D0};
byte rowPins[n_cols] = {D7, D6, D5, D4};
Keypad myKeypad = Keypad( makeKeymap(keys), rowPins, colPins, n_rows, n_cols);
void setup(){
Serial.begin(115200);
}
void loop(){
char myKey = myKeypad.getKey();
if (myKey != NULL){
Serial.print("Key pressed: ");
Serial.println(myKey);
}
}
But later in my project I will need to use another commands and somethings, so I used this one, very similar
`#include <Keypad.h>
const byte n_rows = 4;
const byte n_cols = 4;
char keys[n_rows][n_cols] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte colPins[n_rows] = {D3, 10, 03, D0};
byte rowPins[n_cols] = {D7, D6, D5, D4};
Keypad myKeypad = Keypad( makeKeymap(keys), rowPins, colPins, n_rows, n_cols);
void setup(){
Serial.begin(115200);
}
void loop(){
char keypressed = myKeypad.waitForKey();
if (keypressed != NO_KEY)
{
char c1 = keypressed;
Serial.println(c1);
}
}
But when I upload this on the board, the board starts rebooting, and I get this in the serial monitor
ets Jan 8 2013,rst cause:2, boot mode:(3,6)
load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v09f0c112
~ld
I'm powering it from my computer, and as you can see all I did is changing a function and add a variable
Thanks
Metadata
Metadata
Assignees
Labels
No labels