![]() |
Seeking Help for Code Explanation
Hi there,
I am new to c programming and I am current studying the example codes. I am having difficulty to understand the line Code:
lcd_data(s+48);Here is the full codes: Code:
//Program to interface IR sensor using ADC 0804. Set Vref =1.5v for ADC 0804 |
Re: Seeking Help for Code Explanation
s is a number from 0-9, and 48 is the ASCII character code of the character '0'. So s+48 converts 0-9 to '0'-'9' - this is done 3 times, once for the hundreds digit (so presumably test_final is in the range 0-999), once for the 10s and once for the units. If the first two are zero then it does lcd_cmd(0x06) instead, which I presume moves the cursor one step to the right, so that a value of 36 is not displayed as '036'.
|
| All times are GMT +5.5. The time now is 19:36. |