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
What happens after 9? You Need 2 digits. You can use a C library function or math.
example unsigned char people;
people = HoweverYouCountPeople(); print(people/10); // get 10's digit print(people%10); // get 1's digit (% = modulus)
for 13 that will display "0?"
check the code and see
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
}
Make the room smaller so that it only holds a maximum of 9 people. just make sure none of them are claustrophobic :)
Make the room smaller so that it only holds a maximum of 9 people.
Jon
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).
"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
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]); } }
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
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
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?!
post some code USING THE CORRECT TAGS (see instructions on post page!) please.
no just to print any two digit decimal no.
i didn't get u can u please be more clear.... :)
decimal no. 13
Why 13? Your lucky number?
View all questions in Keil forum