Ad

Converting 'uint8_t' 'float' And 'unsigned Char' Into 'char' For LCD Display

- 1 answer

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?

Ad

Answer

snprintf() is the answer!

Thank you all

Ad
source: stackoverflow.com
Ad