Display a value on the Nokia 5110 LCD Module

Hi,

I'm able to display text on the Nokia 5110 Module, but not values.

For instance
LcdString("123") displays 123

But
int a=123;
LcdString(a);
returns the following error when compiling:

v3_with_LCD:308: error: invalid conversion from 'int' to 'char*'
v3_with_LCD:308: error: initializing argument 1 of 'void LcdString(char*)'

This is LCD String:

void LcdString(char *characters)
{
  while (*characters)
  {
    LcdCharacter(*characters++);
  }
}

and this is LcdCharater:

void LcdCharacter(char character)
{
  LcdWrite(LCD_D, 0x00);//Blank vertical line padding
  for (int index = 0; index < 5; index++)
  {
    LcdWrite(LCD_D, ASCII[character - 0x20][index]);//0x20 is the ASCII character for Space (' '). The font table starts with this character
  }
  LcdWrite(LCD_D, 0x00);
}

So I tried to convert the integer into a string - with no success:

int a=123;
  String astring=String(a);
  LcdString(astring);

Error message:
v3_with_LCD.cpp: In function 'void setup()':
v3_with_LCD:310: error: cannot convert 'String' to 'char*' for argument '1' to 'void LcdString(char*)'

Any help most welcome!

The compiler is telling exactly what the problem is - a String object is not the same as a char*.
There is a String method to convert into a char buffer.

There is a String method to convert into a char buffer.

There is also a function, itoa(), to convert the integer directly to a char array without wasting the resources required by the String class.

You can try the following - I did it as could not print integers as well...

int humid;
int temp;
String humid_r = "0";
String temp_r = "0";

humid_r = humid;
temp_r = temp;

Just save the int as string and print it as string. This works