#PS/2 Keyboard Library#
PS2Keyboard allows you to use a keyboard for user input.
PS/2 Keyboard Library for Arduino
Home Page: http://www.pjrc.com/teensy/td_libs_PS2Keyboard.html
#PS/2 Keyboard Library#
PS2Keyboard allows you to use a keyboard for user input.
is function keys ignored by code as they are defined zero?
Would IT bE possiBLE to ToGGLe on and Off THe LockS KEys AND Leds Using THIs liBRarY?
For those that need it:
An example for PS2 keyboard and standard 16x2 LCD and Keypad shield.
Tested on a mega.
The code includes custom characters for un-supported lcd keys.
lcd row and column numbers are configerable.
/* PS2Keyboard library example
ps2Keyboard1
NB may need to plug usb in after starting the Arduino
Lcd support added 18/2/2018 D.R.Patterson
lcd character set:
http://forum.arduino.cc/index.php?topic=19002.0
Tested on a mega with a Keypad Shield for Arduino
PS2Keyboard now requries both pins specified for begin()
keyboard.begin(data_pin, irq_pin);
Valid irq pins:
Arduino Uno: 2, 3
Arduino Due: All pins, except 13 (LED)
Arduino Mega: 2, 3, 18, 19, 20, 21
Teensy 2.0: All pins, except 13 (LED)
Teensy 2.0: 5, 6, 7, 8
Teensy 1.0: 0, 1, 2, 3, 4, 6, 7, 16
Teensy++ 2.0: 0, 1, 2, 3, 18, 19, 36, 37
Teensy++ 1.0: 0, 1, 2, 3, 18, 19, 36, 37
Sanguino: 2, 10, 11
for more information you can read the original wiki in arduino.cc
at http://www.arduino.cc/playground/Main/PS2Keyboard
or http://www.pjrc.com/teensy/td_libs_PS2Keyboard.html
Like the Original library and example this is under LGPL license.
Modified by [email protected] on 2010-03-22
Modified by Paul Stoffregen <[email protected]> June 2010
*/
#include <PS2Keyboard.h>
const int DataPin = 19;
const int IRQpin = 18;
PS2Keyboard keyboard;
#include <LiquidCrystal.h>
// LCD Keypad Shield for Arduino
// http://www.hobbytronics.co.uk/lcd/lcd-displays-5v/arduino-lcd-keypad-shield
//set constants for number of rows and columns to match your LCD
const int numRows = 2;
const int numCols = 16;
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
byte x, y; // track lcd position
// custom pound using https://omerk.github.io/lcdchargen/
byte customPound[8] = {
0b01100,
0b10010,
0b01000,
0b11100,
0b01000,
0b01000,
0b11110,
0b00000
};
const char pound = 1;
byte customkey[8] = { // ¬
0b00000,
0b00000,
0b00000,
0b00000,
0b11111,
0b00001,
0b00001,
0b00000
};
const char custom = 2;
byte customslash[8] = { // backslash
0b00000,
0b00000,
0b10000,
0b01000,
0b00100,
0b00010,
0b00001,
0b00000
};
const char backslash = 3;
char c;
// currently un-used:
#define is_printable(c) (!(c&0x80)) // don't print if top bit is set
void setup() {
delay(1000);
keyboard.begin(DataPin, IRQpin);
Serial.begin(115200);
while (!Serial) yield();
lcd.begin(numRows, numCols);
delay(250);
lcd.clear();
// create a new custom character
lcd.createChar(pound, customPound);
lcd.createChar(custom, customkey);
lcd.createChar(backslash, customslash);
lcd.cursor(); // Enable Cursor
//lcd.blink(); // Blinking cursor
lcd.clear();
lcd.print(F("Keyboard Test:"));
lcd.setCursor(0,1);
lcd.print(F("Esc to clear LCD"));
Serial.println(F("Keyboard Test:"));
unsigned long t = millis();
do{
if (keyboard.available()) {
c = keyboard.read();
if (c == PS2_ESC) break;
}
} while ((millis() - t) < 8000);
lcd.clear();
}
void loop() {
if (keyboard.available()) {
// read the next key
c = keyboard.read();
// check for some of the special keys
if (c == PS2_ENTER) {
Serial.println();
x = 0;
y += 1;
if (y == numRows){
y = 0;
lcd.clear();
}
lcd.setCursor(x, y);
} else if (c == PS2_TAB) {
lcdprint(F("[Tab]"));
} else if (c == PS2_ESC) {
Serial.println(F("\n[ESC]\n"));
lcd.clear();
x = 0; y = 0;
lcd.setCursor(x, y);
} else if (c == PS2_PAGEDOWN) {
lcdprint(F("[PgDn]"));
} else if (c == PS2_PAGEUP) {
lcdprint(F("[PgUp]"));
} else if (c == PS2_LEFTARROW) {
lcdprint(F("[Left]"));
} else if (c == PS2_RIGHTARROW) {
lcdprint(F("[Right]"));
} else if (c == PS2_UPARROW) {
lcdprint(F("[Up]"));
} else if (c == PS2_DOWNARROW) {
lcdprint(F("[Down]"));
} else if (c == PS2_DELETE) {
lcdprint(F("[Del]"));
} else if (c == PS2_BACKSPACE) {
lcdprint(F("[Back]"));
} else {
// otherwise, just print all normal characters
lcdprintChar(c);
}
}
}
void lcdprintChar(char t){ // display char on lcd and Serial
byte test = byte(t);
if (test == 194) return; // this char appears as an indicator of special keys
if (x > (numCols - 1) ) {
x = 0;
if (y == (numRows - 1)) {
lcd.clear();
Serial.println();
y = 0;
}else y += 1;
Serial.println();
lcd.setCursor(x, y);
}
if (test == 126) lcd.write(243); // 126 ~
else if (test == 163) lcd.write(pound); // 163 £
else if (test == 172) lcd.write(custom); // 194 172 ¬
else if (test == 92) lcd.write(backslash); // 92 backslash
else lcd.print(t);
Serial.print(t);
x += 1;
}
void lcdprint(String t){ // display string on lcd and Serial
byte L = t.length();
if (x > (numCols - L) ) {
x = 0;
if (y == (numRows - 1)) {
lcd.clear();
Serial.println();
y = 0;
}else y += 1;
Serial.println();
lcd.setCursor(x, y);
}
lcd.print(t);
Serial.print(t);
x += L;
}
i connected CLK to the atmega1284 DIP's pin 3 (D2 / INT2), however the interrupt number calculated in PS2Keyboard::begin() was 0, not 2 as expected. took me an awfully long time to realise why ps2interrupt()
wasn't called..
i got the desired value by using digitalPinToInterrupt(irq_pin)
instead of what most of begin()
does - is there any reason not to use the arduino-provided function?
If I use PS2Keyboard configured to UK to output bytes, as numbers instead of the acsii characters, the characters ¬ and £ , both accessed with shift key, cause some strange bytes to be returned, instead of the expected 172 and 163 respectively, it will return -62 -84 for ¬ and then -62 -93 for £. I cannot pinpoint what causes this.
EDIT: It has a problem with any of the codes within PS2Keyboard.h that are above 160.
EDIT: If the code processed is over 127, then 2 numbers are returned. I still haven't worked out why. Yes the example you gives does return the required character, but the set is not expandable beyond 128 as is, if the user wants to return a number from the routine. Can you think of why 2 numbers are being returned if the keycode is above 127?
Use the following code and then SHIFT+3 or SHIFT + ` to reproduce this problem.
Please note that I have changed the pins used to suit my system.
Board Arduino Mega 2560
Shields / modules used N/A
Arduino IDE version 1.8.13
Teensyduino version (if using Teensy) N/A
Version info & package name (from Tools > Boards > Board Manager) 1.8.5
Operating system & version Windows 8.1
Any other software or hardware?
// Change the code below by your sketch (please try to give the smallest code which demonstrates the problem)
#include <Arduino.h>
// libraries: give links/details so anyone can compile your code for the same result
`/* PS2Keyboard library example
PS2Keyboard now requries both pins specified for begin()
keyboard.begin(data_pin, irq_pin);
Valid irq pins:
Arduino Uno: 2, 3
Arduino Due: All pins, except 13 (LED)
Arduino Mega: 2, 3, 18, 19, 20, 21
Teensy 2.0: All pins, except 13 (LED)
Teensy 2.0: 5, 6, 7, 8
Teensy 1.0: 0, 1, 2, 3, 4, 6, 7, 16
Teensy++ 2.0: 0, 1, 2, 3, 18, 19, 36, 37
Teensy++ 1.0: 0, 1, 2, 3, 18, 19, 36, 37
Sanguino: 2, 10, 11
for more information you can read the original wiki in arduino.cc
at http://www.arduino.cc/playground/Main/PS2Keyboard
or http://www.pjrc.com/teensy/td_libs_PS2Keyboard.html
Like the Original library and example this is under LGPL license.
Modified by [email protected] on 2010-03-22
Modified by Paul Stoffregen <[email protected]> June 2010
*/
#include <PS2Keyboard.h>
const int DataPin = 8;
const int IRQpin = 3;
PS2Keyboard keyboard;
void setup() {
delay(1000);
keyboard.begin(DataPin, IRQpin);
Serial.begin(9600);
Serial.println("Keyboard Test:");
}
void loop() {
if (keyboard.available()) {
// read the next key
char c = keyboard.read();
int h = (int)c;
// check for some of the special keys
if (c == PS2_ENTER) {
Serial.println();
} else if (c == PS2_TAB) {
Serial.print("[Tab]");
} else if (c == PS2_ESC) {
Serial.print("[ESC]");
} else if (c == PS2_PAGEDOWN) {
Serial.print("[PgDn]");
} else if (c == PS2_PAGEUP) {
Serial.print("[PgUp]");
} else if (c == PS2_LEFTARROW) {
Serial.print("[Left]");
} else if (c == PS2_RIGHTARROW) {
Serial.print("[Right]");
} else if (c == PS2_UPARROW) {
Serial.print("[Up]");
} else if (c == PS2_DOWNARROW) {
Serial.print("[Down]");
} else if (c == PS2_DELETE) {
Serial.print("[Del]");
} else {
// otherwise, just print all normal characters
Serial.print(c);
Serial.print(" ");
Serial.print(h);
Serial.print(" ");
}
}
}`
If you see any errors or incorrect output, please show it here. Please use copy & paste to give an exact copy of the message. Details matter, so please show (not merely describe) the actual message or error exactly as it appears.
PS2Keyboard.cpp has:
Line 411 : 0, PS2_F10, PS2_F8, PS2_F6, PS2_F4, PS2_TAB, 172 /* ¬ */, 0,
Line 414: 0, 'C', 'X', 'D', 'E', '$', 163 /* £ */, 0,
Both of these lines have a different method of numbering £ and ¬, I suspect there may have been trouble with them before.
ESP8266 is only supported when ARDUINO_ESP8266_NODEMCU is defined. This isn't the case for, e.g., Wemos Mini D1.
Run Simple_Test example on Wemos Mini D1. It doesn't work. Change utility/int_pins.h as follows and it works:
-#elif defined(ARDUINO_ESP8266_NODEMCU)
+#elif defined(ESP8266)
Board Wemos Mini D1
Shields / modules used none
Arduino IDE version 1.8.4
Teensyduino version (if using Teensy) N/A
Version info & package name (from Tools > Boards > Board Manager) esp8266-arduino v2.4.2
Operating system & version Linux Mint Debian Edition
Any other software or hardware?
examples/Simple_Test.ino
See above.
There seems to be a bug in the library in handling of altgr on systems that use progmem. The altgr part of the keymap doesn't work in German.
Looking at the code in line 489 the reason is clear:
' } else if ((state & ALTGR) && keymap->uses_altgr) {'
tries to access keymap->usess_altgr in PROGMEM without properly accessing it through the function pgm_read_byte(). The code line should read
' } else if ((state & ALTGR) && pgm_read_byte(keymap->uses_altgr) ) {'
instead. This works flawlessly.
Hello,
I want to use this library in the way that if I hold a key it won't resend the key in a short intervall (as it is now). The question is: Is this "key-resending" generated by the keyboard's PS2 scancode chip or is it done within the library and could be turned of? Where would I have to look?
for receiving ALT, STR, Win-key ... I would have to the get_iso8859_code() function, right?
Has anybody done this yet?
Greetings, Himi
I am using arduino mega 2560. A PS2 keyboard is connected to read keys & display on segment.
Issue faced is, when power in turned off & applied again on entire system(MCU+PS2 converter+usb keyboard), keyboard don't get initialized again automatically, that is I am not able to read any keys unless I remove the keyboard from socket & connect again, then I can read again.
There is small USb to PS2 converter used. Keyboard is usb.
what could be issue.
below is keyboard code:
const int DataPin = 19;
const int IRQpin = 18;
PS2Keyboard keyboard;
keyboard.begin(DataPin, IRQpin);
keyboard.clear();
c = keyboard.read();
Serial.println(c);
When trying to compile the examples (i.e. "international.ino" to get started) using µCs from Mighty Core (i.e. ATmega644) and MiniCore(i.e. ATmega328), I get the following error:
W:\libraries\PS2Keyboard\PS2Keyboard.cpp:271:1: error: narrowing conversion of '-15708' from 'int' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
};
and the warnings:
W:\libraries\PS2Keyboard\PS2Keyboard.cpp:265:53: warning: multi-character character constant [-Wmultichar]
0 /CapsLock/, 0 /Rshift/, PS2_ENTER /Enter/, '¤', 0, '#', 0, 0,
^~~~
W:\libraries\PS2Keyboard\PS2Keyboard.cpp:153:1: warning: missing initializer for member 'PS2Keymap_t::altgr' [-Wmissing-field-initializers]
};
Using the ProMini (also an ATmega328), Nano etc., everything compiles absolutely fine, no warnings, no errors.
As I do need the 644 and other µC from the Mighty- and MiniCore Libs, any idea how to overcome this problem ?
Thanks in advance !
I miss the F-Keys.
There comes senseless output if I press them.
I have edit the codes in the lib but can't get them in my script. All other codes, who are originaly in the script, are all correct delivered.
Is it not possible to catch the F-Keys?
Arduino version : 1.18.15.
Library doe not work with Arduino Zero. Is there a workaround?
For those that need it, here is a keyboard lcd example, tested on a mega with a standard 16x2 LCD and Keypad shield:
It includes custom characters for un-supported lcd keys.
``
/* PS2Keyboard library example
ps2Keyboard1
NB may need to plug usb in after starting the Arduino
Lcd support added 18/2/2018 D.R.Patterson
lcd character set:
http://forum.arduino.cc/index.php?topic=19002.0
Tested on a mega with a Keypad Shield for Arduino
PS2Keyboard now requries both pins specified for begin()
keyboard.begin(data_pin, irq_pin);
Valid irq pins:
Arduino Uno: 2, 3
Arduino Due: All pins, except 13 (LED)
Arduino Mega: 2, 3, 18, 19, 20, 21
Teensy 2.0: All pins, except 13 (LED)
Teensy 2.0: 5, 6, 7, 8
Teensy 1.0: 0, 1, 2, 3, 4, 6, 7, 16
Teensy++ 2.0: 0, 1, 2, 3, 18, 19, 36, 37
Teensy++ 1.0: 0, 1, 2, 3, 18, 19, 36, 37
Sanguino: 2, 10, 11
for more information you can read the original wiki in arduino.cc
at http://www.arduino.cc/playground/Main/PS2Keyboard
or http://www.pjrc.com/teensy/td_libs_PS2Keyboard.html
Like the Original library and example this is under LGPL license.
Modified by [email protected] on 2010-03-22
Modified by Paul Stoffregen [email protected] June 2010
*/
#include <PS2Keyboard.h>
const int DataPin = 19;
const int IRQpin = 18;
PS2Keyboard keyboard;
#include <LiquidCrystal.h>
// LCD Keypad Shield for Arduino
// http://www.hobbytronics.co.uk/lcd/lcd-displays-5v/arduino-lcd-keypad-shield
//set constants for number of rows and columns to match your LCD
const int numRows = 2;
const int numCols = 16;
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
byte x, y; // track lcd position
// custom pound using https://omerk.github.io/lcdchargen/
byte customPound[8] = {
0b01100,
0b10010,
0b01000,
0b11100,
0b01000,
0b01000,
0b11110,
0b00000
};
const char pound = 1;
byte customkey[8] = { // ¬
0b00000,
0b00000,
0b00000,
0b00000,
0b11111,
0b00001,
0b00001,
0b00000
};
const char custom = 2;
byte customslash[8] = { // backslash
0b00000,
0b00000,
0b10000,
0b01000,
0b00100,
0b00010,
0b00001,
0b00000
};
const char backslash = 3;
char c;
// currently un-used:
#define is_printable(c) (!(c&0x80)) // don't print if top bit is set
void setup() {
delay(1000);
keyboard.begin(DataPin, IRQpin);
Serial.begin(115200);
while (!Serial) yield();
lcd.begin(numRows, numCols);
delay(250);
lcd.clear();
// create a new custom character
lcd.createChar(pound, customPound);
lcd.createChar(custom, customkey);
lcd.createChar(backslash, customslash);
lcd.cursor(); // Enable Cursor
//lcd.blink(); // Blinking cursor
lcd.clear();
lcd.print(F("Keyboard Test:"));
lcd.setCursor(0,1);
lcd.print(F("Esc to clear LCD"));
Serial.println(F("Keyboard Test:"));
unsigned long t = millis();
do{
if (keyboard.available()) {
c = keyboard.read();
if (c == PS2_ESC) break;
}
} while ((millis() - t) < 8000);
lcd.clear();
}
void loop() {
if (keyboard.available()) {
// read the next key
c = keyboard.read();
// check for some of the special keys
if (c == PS2_ENTER) {
Serial.println();
x = 0;
y += 1;
if (y == numRows){
y = 0;
lcd.clear();
}
lcd.setCursor(x, y);
} else if (c == PS2_TAB) {
lcdprint(F("[Tab]"));
} else if (c == PS2_ESC) {
Serial.println(F("\n[ESC]\n"));
lcd.clear();
x = 0; y = 0;
lcd.setCursor(x, y);
} else if (c == PS2_PAGEDOWN) {
lcdprint(F("[PgDn]"));
} else if (c == PS2_PAGEUP) {
lcdprint(F("[PgUp]"));
} else if (c == PS2_LEFTARROW) {
lcdprint(F("[Left]"));
} else if (c == PS2_RIGHTARROW) {
lcdprint(F("[Right]"));
} else if (c == PS2_UPARROW) {
lcdprint(F("[Up]"));
} else if (c == PS2_DOWNARROW) {
lcdprint(F("[Down]"));
} else if (c == PS2_DELETE) {
lcdprint(F("[Del]"));;
} else if (c == PS2_BACKSPACE) {
lcdprint(F("[Back]"));
} else {
// otherwise, just print all normal characters
lcdprintChar(c);
}
}
}
void lcdprintChar(char t){ // display char on lcd and Serial
byte test = byte(t);
if (test == 194) return; // this char appears as an indicator of special keys
if (x > (numCols - 1) ) {
x = 0;
if (y == (numRows - 1)) {
lcd.clear();
Serial.println();
y = 0;
}else y += 1;
Serial.println();
lcd.setCursor(x, y);
}
if (test == 126) lcd.write(243); // 126 ~
else if (test == 163) lcd.write(pound); // 163 £
else if (test == 172) lcd.write(custom); // 194 172 ¬
else if (test == 92) lcd.write(backslash); // 92 backslash
else lcd.print(t);
Serial.print(t);
x += 1;
}
void lcdprint(String t){ // display string on lcd and Serial
byte L = t.length();
if (x > (numCols - L) ) {
x = 0;
if (y == (numRows - 1)) {
lcd.clear();
Serial.println();
y = 0;
}else y += 1;
Serial.println();
lcd.setCursor(x, y);
}
lcd.print(t);
Serial.print(t);
x += L;
}
Minor changes to US map to work with a uk keyboard:
const PROGMEM PS2Keymap_t PS2Keymap_US = {
// without shift
{0, PS2_F9, 0, PS2_F5, PS2_F3, PS2_F1, PS2_F2, PS2_F12,
0, PS2_F10, PS2_F8, PS2_F6, PS2_F4, PS2_TAB, '`', 0,
0, 0 /Lalt/, 0 /Lshift/, 0, 0 /Lctrl/, 'q', '1', 0,
0, 0, 'z', 's', 'a', 'w', '2', 0,
0, 'c', 'x', 'd', 'e', '4', '3', 0,
0, ' ', 'v', 'f', 't', 'r', '5', 0,
0, 'n', 'b', 'h', 'g', 'y', '6', 0,
0, 0, 'm', 'j', 'u', '7', '8', 0,
0, ',', 'k', 'i', 'o', '0', '9', 0,
0, '.', '/', 'l', ';', 'p', '-', 0,
0, 0, ''', 0, '[', '=', 0, 0,
0 /CapsLock/, 0 /Rshift/, PS2_ENTER /Enter/, ']', 0, '#', 0, 0, //drp \ to #
0, '\', 0, 0, 0, 0, PS2_BACKSPACE, 0, //drp \ added
0, '1', 0, '4', '7', 0, 0, 0,
'0', '.', '2', '5', '6', '8', PS2_ESC, 0 /NumLock/,
PS2_F11, '+', '3', '-', '', '9', PS2_SCROLL, 0,
0, 0, 0, PS2_F7 },
// with shift
{0, PS2_F9, 0, PS2_F5, PS2_F3, PS2_F1, PS2_F2, PS2_F12,
0, PS2_F10, PS2_F8, PS2_F6, PS2_F4, PS2_TAB, '¬', 0, //drp ~ to ¬
0, 0 /Lalt/, 0 /Lshift/, 0, 0 /Lctrl/, 'Q', '!', 0,
0, 0, 'Z', 'S', 'A', 'W', '"', 0, //drp @ to "
0, 'C', 'X', 'D', 'E', '$', '£', 0, //drp # to £
0, ' ', 'V', 'F', 'T', 'R', '%', 0,
0, 'N', 'B', 'H', 'G', 'Y', '^', 0,
0, 0, 'M', 'J', 'U', '&', '', 0,
0, '<', 'K', 'I', 'O', ')', '(', 0,
0, '>', '?', 'L', ':', 'P', '_', 0,
0, 0, '@', 0, '{', '+', 0, 0, //drp " to @
0 /CapsLock/, 0 /Rshift/, PS2_ENTER /Enter/, '}', 0, '~', 0, 0, //drp | to ~
0, '|', 0, 0, 0, 0, PS2_BACKSPACE, 0, //drp | added
0, '1', 0, '4', '7', 0, 0, 0,
'0', '.', '2', '5', '6', '8', PS2_ESC, 0 /NumLock/,
PS2_F11, '+', '3', '-', '*', '9', PS2_SCROLL, 0,
0, 0, 0, PS2_F7 },
0
};
According to picture that you put on: https://www.pjrc.com/teensy/td_libs_PS2Keyboard.html
The +5V line is on the right. This seems to be wrong, for example see:
[1] https://web.archive.org/web/20060901070855/http://www.computer-engineering.org/ps2protocol/
[2] https://en.wikipedia.org/wiki/PS/2_port
IMHO you should make it explicit if the pinout is for female or male connector.
Any reason why PS2_BACKSPACE definition can not be different to delete?
#define PS2_BACKSPACE 1 //drp 127 to 1
With the ESP32 I got some wrong output.
When i press the same button on the keyboard sometimes another letter will appear on the Serial Output.
Serial Abnormal output
⸮a'B⸮R+⸮R#⸮⸮�⸮⸮⸮ԅu⸮⸮b!⸮⸮(⸮⸮� 09:25:12.160 -> ⸮D�(⸮⸮⸮⸮⸮⸮ܦ⸮⸮⸮⸮⸮⸮H#9⸮⸮⸮!⸮⸮D�˗⸮b!⸮⸮)⸮(⸮⸮⸮J(�D⸮⸮⸮⸮�)⸮)⸮⸮⸮J(�D⸮⸮⸮H⸮⸮⸮19⸮⸮!⸮⸮⸮⸮Q)⸮(⸮⸮⸮J(�D⸮S⸮R�)⸮�⸮⸮@Hʨ0�z⸮⸮⸮⸮!⸮⸮⸮!�⸮⸮H⸮⸮ԅ9⸮⸮⸮!⸮H⸮⸮⸮܆-⸮⸮@a⸮9⸮H�⸮H!⸮⸮T9⸮⸮⸮!⸮⸮⸮⸮⸮!⸮⸮D�9;⸮⸮⸮⸮H!⸮⸮U9⸮⸮⸮!⸮�9⸮⸮܆⸮⸮⸮d⸮⸮H#9⸮⸮f!⸮⸮D�˗⸮f!H⸮⸮⸮!⸮⸮⸮!�⸮⸮!?3⸮⸮x⸮⸮@⸮1⸮H�⸮⸮�)⸮)⸮⸮⸮J(⸮D⸮⸮⸮?⸮܆⸮⸮⸮@⸮1⸮H�⸮!⸮⸮L⸮⸮&!⸮ ⸮/⸮v!⸮⸮D⸮9;⸮⸮⸮⸮⸮⸮V!⸮⸮D�˗⸮f!⸮�)⸮�⸮⸮@Hʪ0��⸮V�)3�⸮⸮@H6⸮0⸮⸮�?�)⸮�⸮⸮@H:⸮0�⸮⸮(⸮⸮
�
09:25:42.580 -> ⸮D�×⸮⸮⸮
As long as it is started, it will output, even if the keyboard is not connected
#include <PS2Keyboard.h>
#include <ps2dev.h>
#define D0 16
#define D1 5
#define D2 4
#define D3 0
#define D4 2
#define D5 14
#define D6 12
#define D7 13
#define D8 15
PS2Keyboard keyboard_r;
//PS2dev keyboard(D1 , D2); //clock, data
void setup() {
// put your setup code here, to run once:
delay(1000);
keyboard_r.begin(D3, D1); // DataPin, IRQpin
Serial.begin(9600);
Serial.println("Keyboard Test:");
}
void loop() {
// put your main code here, to run repeatedly:
// if (keyboard_r.available()) {
// uint8_t s;
// // s = keyboard_r.readScanCode();
// s = keyboard_r.read();
// if (s){
//erial.println(s, HEX);
//keyboard.write(s);
// }
}
// }
Example files don't compile.
Using Arduino IDE 1.8.6
C:\Users\Justus\Documents\Arduino\libraries\PS2Keyboard\PS2Keyboard.cpp:271:1: error: narrowing conversion of '-15708' from 'int' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
};
^
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.