I'm new in the Arduino Community and I'm facing a problem when I try to use a PS2 Keyboard and an LCD Display (16x2) on an Arduino Uno with a Wifi shield.
I would like to write something with the keyboard and display it in the LCD before sending it to a webservice.
Here is my problem:
- When I use the keyboard and the display on my Arduino WITHOUT the wifi shield --> All is OK. I can write on the display the key that has been pressed.
- When I use the keyboard and the display on my Arduino WITH the wifi shield --> All is OK until I write something on the display. As soon as I write on the display with the function lcd.print(), the keyboard does not work anymore (it detect the character '2' every time I press a key).
It's very surprisingly because if I dont use lcd.print(), the keybord works without any problem.
Here is a part of my code:
#include <LiquidCrystal.h>
#include <PS2Keyboard.h>
LiquidCrystal lcd(12, 11, 2, 5, 6, 8);
PS2Keyboard keyboard;
const int DataPin = 9;
const int IRQpin = 3;
void setup(){
keyboard.begin(DataPin, IRQpin);
lcd.begin(16, 2);
}
void loop(){
checkKeyboard();
}
void checkKeyboard(){
if (keyboard.available()) {
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("[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 {
Serial.print(c);
displayText(c);
}
}
}
void displayText(char c){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Pressed key:");
lcd.setCursor(0,1);
lcd.print(c);
}
Does somebody know how to solve this problem?
Thank you very much in advance :)
Edit: Here are the pins that I use on the board :
- Arduino pin 2 -> LCD pin 11
- Arduino pin 5 -> LCD pin 12
- Arduino pin 6 -> LCD pin 13
- Arduino pin 8 -> LCD pin 14
- Arduino pin 11 -> LCD pin 6
- Arduino pin 12 -> LCD pin 4
- Arduino pin 3 -> Keyboard IRQ
- Arduino pin 9 -> Keyboard Data