I have some reading 3 digit value from ADC and the value shown is on LCD in the form of Characters.. now i wish to put some condition on that 3 digit value like 078 i want this value to be in int...how to convert value shown on lcd to int so i can put condition on it..to do some action...
i m reading Data from LM35 as temperature measurement. But directly i cannot use if lcd > 100 so i need to convert it to int value then i can put condition...... please advice...
Code:
a = t%10;
lcd[2] = a + '0';
t = t/10;
a = t%10;
lcd[1] = a + '0';
t = t/10;
a = t%10;
lcd[0] = a + '0';
Lcd_out(1,12,lcd);
character value - 0x30 or - d48 is int value. You can save the original int value to another int variable and use it for the if() condition. No need to convert char to int.
yes i got it i can take lcdint as another variable storing the value of lcd character as int value... could you please show me example... because m not fully clear how to use -d48 ?
'2' - 0x30 = 2 and '2' - 48 = 2. d48 is decimal 48. You don't have to store LCD character as int variable. Before you send int data to LCD it will be in int format. Just make a copy of that int and use it in if condition because I see your original int value gets modified in the int to str conversion routine.
Your t is the original int and it changes its value in the int to str conversion routine. So, save t value to iadc_val (int variable). Use iadc_val in if condition. Forget about char to int conversion.
If you want to use the ADC integer result then it would make sense to keep it so use a second variable and keep the result there for any calculations you want to do since you change the variable t and can't be used.