nokia 5110 lcd + PS2 keyboard help

Hello guys, i am a newbie into C++ programming and i have a problem making this to work,

the point is when i type a character it should be displayed on the 5110 lcd, but i see only weird Japanese characters :smiley: so i have no idea what to do i added dtostrf() function but now i gives me ascii caracters 97 for 'a'... can someone help me with this, thanks in advance :neutral_face:

i am using LCD5110_Graph library : LCD5110_Graph - Rinky-Dink Electronics

#include <PS2Keyboard.h>
#include <Wire.h>
#include <LCD5110_Graph.h>

LCD5110 lcd(8, 9, 10, 12, 11);
extern unsigned char SmallFont[];

const int DataPin = 4;
const int IRQpin =  3;

int x;
int y;
char c;



PS2Keyboard keyboard;

void setup() {
  delay(1000);
  keyboard.begin(DataPin, IRQpin);
  Serial.begin(9600);
  Serial.println("Keyboard Test:");
  lcd.InitLCD();
  lcd.setFont(SmallFont);
  lcd.print("Keyboard Test:" , CENTER , 10);
  lcd.update();
  delay(1000);
  lcd.clrScr();
}





void loop() {
  if (keyboard.available()) {

    // read the next key
    c = keyboard.read();
    Serial.print(c);

   char hu[6];
   dtostrf(c, 5, 0, hu);

    lcd.setFont(SmallFont);
    lcd.print(hu , CENTER , 15);
    lcd.update();
    delay(1000);
    lcd.clrScr();

  }

}

The default implementation of the PS2Keyboard library has only a lookup table for the numblock. All other keys will return the keyboard scancode and not the ASCII value. I would have expected a different value though if 'A' is pressed (28 instead of 97). You can find the relevant key codes here: http://www.computer-engineering.org/ps2keyboard/scancodes2.html

on the serial monitor the c variable which hold the character i type is correct, if i type a it show a, but on the lcd it gives me random pixels, i don't know what's wrong, that's why i have added the dtostrf() just to see if it will work with it,

it should be : lcd.print(c , CENTER , 15);

instead of

lcd.print(hu , CENTER , 15);

I think that library expects a null terminated string. Try modifying your code to the following and see if you get the correct character.

     char hu[6];
     hu[0] = c;
     hu[1] = '\0';


     lcd.setFont(SmallFont);
     lcd.print(hu , CENTER , 15);
     lcd.update();
     delay(1000);
     lcd.clrScr();

Thank you it worked :slight_smile: can you please explain to me what exactly does do hu[0] = c; hu[1] = '\0'; i didn't understand this null terminated string, thank you again