I want to interface ps2 keyboard with esp8266 but cant find any library so it tried a code and it worked 50% because when i start typing after 20 to 25 letters the esp8266 gets RESETS.
The serial shows this error
ets Jan 8 2013,rst cause:4, boot mode:(3,6)
wdt reset
load 0x4010f000, len 3424, room 16
tail 0
chksum 0x2e
load 0x3fff20b8, len 40, room 8
tail 0
chksum 0x2b
csum 0x2b
v00042040
here is my code
char ScancodeToASCII[2][128] = {
{ 0,0,0,0,0,0,0,0, 0,0,0,0,0,9,94,0, 0,0,0,0,0,113,49,0, 0,0,121,115,97,119,50,0, // w/o SHIFT or ALT(GR)
0,99,120,100,101,52,51,0,0,32,118,102,116,114,53,0,0,110,98,104,103,122,54,0,0,0,109,106,117,55,56,0,
0,44,107,105,111,48,57,0,0,46,45,108,148,112,0,0, 0,0,132,0,129,96,0,0, 0,0,10,43,0,35,0,0,
0,60,0,0,0,0,8,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,27,0, 0,0,0,0,0,0,0,0 },
{ 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,248,0, 0,0,0,0,0,81,33,0, 0,0,89,83,65,87,34,0, // with SHIFT
0,67,88,68,69,36,0,0, 0,0,86,70,84,82,37,0, 0,78,66,72,71,90,38,0, 0,0,77,74,85,47,40,0,
0,59,75,73,79,61,41,0, 0,58,95,76,153,80,63,0, 0,0,142,0,154,0,0,0, 0,0,0,42,0,39,0,0,
0,62,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0 } };
volatile bool shiftIsActive = false;
volatile bool nextIsReleased = false;
void setup() {
pinMode(5, INPUT_PULLUP); // connected to D1 (GPIO5)
pinMode(4, INPUT_PULLUP); // connected to D2 (GPIO4)
attachInterrupt(digitalPinToInterrupt(4), ISRFunction, CHANGE);
Serial.begin(115200);
}
void loop() {
// Your main code, if any, can go here
}
ICACHE_RAM_ATTR void ISRFunction() {
int val = 0;
for (int i = 0; i < 11; i++) {
while (digitalRead(5) == HIGH);
val |= digitalRead(4) << i;
while (digitalRead(5) == LOW);
}
val = (val >> 1) & 255;
switch (val) {
case 18: case 89: shiftIsActive = !nextIsReleased; nextIsReleased = false; break;
case 240: nextIsReleased = true; break;
default:
if (!nextIsReleased) { // is it a 'key pressed' event?
Serial.print(ScancodeToASCII[shiftIsActive][val & 127]);
}
nextIsReleased = false;
break;
}
}