I am trying to make a very basic ps2 keyboard controller. I want to be able to type in certain words for instance "LEDON" and use that to trigger led's. I was basing this code on the sample ps2 keyboard code.:
#include <PS2Keyboard.h>
const int DataPin = 8;
const int IRQpin = 2;
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();
// 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("");
} else if (c == PS2_RIGHTARROW) {
Serial.print("");
} else if (c == PS2_UPARROW) {
Serial.print("[Up]");
} else if (c == PS2_DOWNARROW) {
Serial.print("[Down]");
} else if (c == PS2_DELETE) {
Serial.print("");
} else {
// otherwise, just print all normal characters
Serial.print(c);
}
}
}
[#include <PS2Keyboard.h>
const int DataPin = 8;
const int IRQpin = 2;
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();
// 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("");
} else if (c == PS2_RIGHTARROW) {
Serial.print("");
} else if (c == PS2_UPARROW) {
Serial.print("[Up]");
} else if (c == PS2_DOWNARROW) {
Serial.print("[Down]");
} else if (c == PS2_DELETE) {
Serial.print("");
} else {
// otherwise, just print all normal characters
Serial.print(c);
}
}
}
I think it is a string that I need to use but I'm not sure exactly how it works. I am a beginner in using the arduino and was just wondering how this is possible to do. I was looking at bits a pieces of tiny basic emulators for the arduino that use this but I'm not sure exactly how to set it up. I have the sample code working if that is helpfull