Good Evening!
I am experiencing problem regarding conversion of char data type to int, I am using Current Transformer analogue reading to be printed to 16x4 LCD, for that I had to do some calculation stuff, but now to calculate KWh, i have to use that Current value but i could not use it because of it to be char type. Kindly see my code and suggest me possible ways out of it. Thank you!
Code:
int c11=A0;
long tempc;
long tempReading1;
long i1;
char d1=0;
char d2=0;
char d3=0;
char d4=0;
void setup() {
Serial.begin(9600);
}
void CT()
{
tempReading1 = analogRead(c11);
tempc = tempReading1 * 5000 / 1024;
i1=tempc;
lcd.setCursor(0,1);
Serial.print("CURRENT=");
d1=tempc/1000;
d2=(tempc/100)%10;
d3=(tempc/10)%10;
d4=d1+d2+d3;
lcd.print(d1+48);
lcd.print('.');
lcd.print(d2+48);
lcd.write(d4+48);
lcd.println('A');
}