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.
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
A friend of mine also tried to print all decimals. He got tired after having printed the first billions of numbers. How much patience do you have?
By the way - exactly what do you expect to happen after 9?
How would you express 1,104,184,835,583 if you expect each decimal number to be represented by a single character. Even if using UTF instead of ASCII, the number of defined characters is very limited. UTF16 can have max 2^16 characters which would only cover 0 to 65535 if used just to store the first non-negative integers.
For hexadecimal, the next value to print would after 9 be A, but for decimal, it's time to switch to two digits. What have you done in your code to switch to two digits instead of just trying to use the next ASCII character available?
decimal no. 13
Why 13? Your lucky number?
i didn't get u can u please be more clear.... :)
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]); } }
"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