hi friends i am trying to print all the decimal no's on LCD but i am able to print till 9 only after that i am getting : ; so on
decimal no. 13
Why 13? Your lucky number?
no just to print any two digit decimal no.
post some code USING THE CORRECT TAGS (see instructions on post page!) please.
If you can print a single-digit, then printing two (or more) digits is just a matter of repeating exactly the same process twice (or more) - surely?!
ie,
lcd_print_digit( 1 ); lcd_print_digit( 3 );
where lcd_print_digit is a function which takes as its argument the numerical value of each digit.
Alternatively, if you have a function that takes the character code:
lcd_print_char( '1' ); lcd_print_char( '3' );
In general:
WHILE there are more digits DO print next digit
Actually i am trying to write program to count the no of persons entering a room i am getting correctly till 9 but after that...... problem...... can u please provide me any help
Either make use of sprintf() to convert your number into a string of one or more characters. Then loop through the full length of the string and emit the characters one-by-one.
Or convert the number by repetetively extracting the smallest digit and reducing the number by a factor 10. Emit the digits in reverse order.
void lcd_print_num(unsigned num) { char queue[MAX_QUEUE_DEPTH]; unsigned queue_pos = 0; while (num > 0) { queue[queue_pos++] = (num % 10) + '0'; num /= 10; } if (queue_pos == 0) queue[queue_pos++] = '0'; while (queue_pos) { lcd_print_character(queue[--queue_pos]); } }
View all questions in Keil forum