- This topic has 1 reply, 2 voices, and was last updated 10 years, 3 months ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.
|
Microcontroller › 8051 › explain about temprature project code
hi,
I have a problem in code of “ Celsius and Fahrenheit scale digital thermometer using 8051 microcontroller (AT89C51)” project in these line:
…….
test_final=test_intermediate3;
lcd_cmd(0xc1); //Setting cursor to first position of first line
delay(2);
lcd_data_string(“TEMP:”);
s=test_final/100;
test_final=test_final%100;
lcd_cmd(0xc8);
if(s!=0)
lcd_data(s+48);
else
lcd_cmd(0x06);
s=test_final/10;
test_final=test_final%10;
lcd_data(s+48);
lcd_data(test_final+48);
lcd_data(0);
lcd_data(‘c’);
lcd_data(‘ ‘);
delay(2);
……
please explain bold lines of code and why plus 48 to the results?
Hi,
48 is added to any sigle digit value to get its ascii value, because ascii value of 0 is 48.
To get ascii value of 1, use 1+48
To get ascii value of 2, use 2+48