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
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]); } }
"problem...... can u please provide me any help"
You need to debug your program!
The first thing to do is to determine whether the problem lies in the counting, or in displaying the number.
Tips for debugging: www.8052.com/.../120313
Man, this guy is so clueless (and he does have the capacity to read a given solution. It must be compiled and zipped and shipped).
Make the room smaller so that it only holds a maximum of 9 people.
Jon
Make the room smaller so that it only holds a maximum of 9 people. just make sure none of them are claustrophobic :)
Erik
void disp_no(uc k) { uc k; dat=k; k=k&0xf0; k=k>>4; k=k|0x30; print this value; k=dat; k=k &0x0f; k=k|0x30; print this value in to lcd
}
for 13 that will display "0?"
check the code and see