Search code examples
cavratmega

Converting 'uint8_t' 'float' and 'unsigned char' into 'char' for LCD display


I'm working on AtMega88PA with well-working LCD display.

I've got 2 working methods from the internet:

extern void lcd_putc(char c);          // send one 'char' to LCD display e.g. lcd_putc('A')
extern void lcd_puts(const char *s);   // send more chars e.g lcd_puts("something")

And those are working great. However if I want to send uint8_t LCD is showing weird symbol - 4 horizontal lines.

I've tried to project this integer using:

lcd_putc((char) integer); 

Both outside and inside function, with same result. I also tried to convert a number from BCD to Decimal and otherwise. It's same for unsigned char - for some reason when I try to display unsigned char same character appears on LCD display.

How do I convert other data types into char in C?


Solution

  • snprintf() is the answer!

    Thank you all