We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I wish to display the contents of a variable, probably an unsigned integer, on an lcd display driven from the 8051. I have written software to accept an array of characters and write these, so the ideal would be to creat a similat array from the variable. I have tried the basic ways I know of, sprintf (char_array, "%d", integer_value); (very low tech) but dosent work. Any pointers would be greatfully recieved, Thank you, Tim
If the number is an unsigned integer,you may have to use %u instead of %d in the sprintf function to get the correct string. sprintf (char_array, "%d", integer_value);
Note that unless you enable ANSI integer promotion, a byte variable cannot be printed with "%d". Those format specifiers only work with integers, which are two bytes long. To print bytes, you need to use "%bd" (etc), in much the same way you need "%ld" for a 32-bit long.