Arduino Uno + Wifi Shield + PS2 Keyboard + LCD Display

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 :slight_smile:

Does somebody know how to solve this problem?

Certainly.

LiquidCrystal lcd(12, 11, 2, 5, 6, 8);

Don't connect the LCD to the SPI pins. Pins 10, 11, 12, and 13 are NOT available for you to use.

Thank you PaulS, you are my hero. By using the pins 4 and 7 instead of 11 and 12. All works well :slight_smile:

I would use another pin besides D7. This is from the reference page for the wifi shield.

Digital pin 7 is used as a handshake pin between the WiFi shield and the Arduino, and should not be used.

Be advised that if you use D4, you can't use the SD card slot.

You are right. Now, as soon as I use the wifi, my lcd display doesn't work anymore :cry:

What are my possibilities? If I resume the current situation:

Arduino Pin 0 ->
Arduino Pin 1 ->
Arduino Pin 2 -> LCD Pin 4 (RS)
Arduino Pin 3 -> Keyboard IRQ
Arduino Pin 4 -> LCD Pin 11 (D4)
Arduino Pin 5 -> LCD Pin 12 (D5)
Arduino Pin 6 -> LCD Pin 13 (D6)
Arduino Pin 7 -> LCD Pin 6 (E)
Arduino Pin 8 -> LCD Pin 14 (D7)
Arduino Pin 9 -> Keyboard Data
Arduino Pin 10 ->
Arduino Pin 11 ->
Arduino Pin 12 ->
Arduino Pin 13 ->

Thank you in advance

PS: It's not a problem if I can't use the SD Card

Maybe you can use the analog pins as digital pins. I haven't tried it, but others say it can be done.
A0 = D14
A1 = D15
A2 = D16
A3 = D17

SurferTim:
Maybe you can use the analog pins as digital pins. I haven't tried it, but others say it can be done.
A0 = D14
A1 = D15
A2 = D16
A3 = D17

It works very well !!!!

Everything is OK now. Thank you :slight_smile: