Author Topic: nokia 5110 lcd + PS2 keyboard help  (Read 1123 times)

0 Members and 1 Guest are viewing this topic.

Offline Mugiwara303Topic starter

  • Contributor
  • Posts: 28
  • Country: ma
    • TheGameScene
nokia 5110 lcd + PS2 keyboard help
« on: November 11, 2016, 03:57:10 pm »
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 ;D 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

i am using LCD5110_Graph library : http://www.rinkydinkelectronics.com/library.php?id=47

Code: [Select]
#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();

  }

}
 

Offline MickM

  • Regular Contributor
  • *
  • Posts: 100
Re: nokia 5110 lcd + PS2 keyboard help
« Reply #1 on: November 13, 2016, 11:58:30 pm »
Put in some "printf()" statements.
At least for "c" and "hu" in loop().

I am not familiar with keyboard.read().

You may be reading the wrong char, using the wrong font, or going too fast for the lcd display.
Also the raw keyboard data is not ascii.

Mick M.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf