I am using OneWire to get temp input and trying to output the value on the LCD screen. So when I output the value using Serial.print(val) it is correct but if I use lcd.print(val) it comes up as a CHAR.
for example:
int val = 70;
Serial.print(val); // outputs 70 to the console
lcd.print(val); // outputs F to the LCD.
I am very new to this and the code i have is all basically found in forums and examples.
here is the loop function I have so far.
Any help is greatly appreciated!!
void loop()
{
int HighByte, LowByte, TReading, SignBit, Tc_100, Tf_100, Fract;
float Whole;
digitalWrite(13, HIGH); //light the debug LED
OneWireReset(TEMP_PIN); // reset
OneWireOutByte(TEMP_PIN, 0xcc); // skip ROM code
OneWireOutByte(TEMP_PIN, 0x44); // perform temperature conversion, strong pullup for one sec
OneWireReset(TEMP_PIN); // reset
OneWireOutByte(TEMP_PIN, 0xcc); // skip ROM code
OneWireOutByte(TEMP_PIN, 0xbe); // Read scratchpad code (temperature in this case)
LowByte = OneWireInByte(TEMP_PIN);
HighByte = OneWireInByte(TEMP_PIN);
TReading = (HighByte << 8) + LowByte;
SignBit = TReading & 0x8000; // test most sig bit
if (SignBit) // negative
{
TReading = (TReading ^ 0xffff) + 1; // 2's complement the answer
}
Tc_100 = (6 * TReading) + TReading / 4; // multiply by (100 * 0.0625) or 6.25
Whole = Tc_100 / 100; // separate off the whole and fractional portions
Fract = Tc_100 % 100;
if (SignBit) // If its negative
{
lcd.printIn("-");
}
if (Fract < 10)
{
//lcd.printIn("0");
}
//lcd.print("C\n");
Tf_100 = ((Tc_100 * 9) / 5) + 3200;
Whole = Tf_100 / 100; // separate off the whole and fractional portions
Fract = Tf_100 % 100;
if (SignBit) // If its negative
{
lcd.printIn("-");
}
lcd.clear();
lcd.print(Whole);
Serial.print(Whole);
Serial.println();
if (Fract < 10)
{
//lcd.printIn("0");
}
//lcd.print(Fract);
//scroll entire display 20 chars to left, delaying 50ms each inc
//lcd.leftScroll(20, 50);
delay(2000); // 2 second delay. Adjust as necessary
//lcd.clear();
}