Trying to get my serial monitor output (tempature readings) to show up on my LCD (2x16) but not having any luck.
I think my problem may lie with the way I have my serial outputs.
Serial.print("Celcius: ");
float temperature = (voltage - .5) * 100;
Serial.print(temperature);
Serial.println(" degrees.");
delay(1000);
If you can toss me a life raft that would be amazing. Here is my code. (very early stages)
Thanks
~Wayne
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
//°C x 9/5 + 32 = °F
const int sensorPin = A0; //Sensor constant
const int degreePin = 8; // the number of the degreebutton pin
int switchState = 0;
const int printPin = 9; // the number of the print pin
int Print = 0;
void setup()
{
Serial.begin(9600); // open a serial connection to display values
pinMode(degreePin, INPUT); //initialize the degreePin button as an input
pinMode(printPin, INPUT); //initialize the degreePin button as an input
lcd.begin(16, 2);
}
void loop(){
int sensorVal = analogRead(sensorPin); // read the value on AnalogIn pin 0 and store it in a variable
float voltage = (sensorVal/1024.0) * 5.0; // convert the ADC reading to voltage
switchState = digitalRead(degreePin);
Print = digitalRead(printPin);
if(Print == HIGH)
{
if(switchState == HIGH)
{
Serial.print("Fahrenheit: ");
float Ftemperature = (((voltage - .5) * 100) * 1.8 + 32);
Serial.print(Ftemperature);
Serial.println(" degrees.");
delay(1000);
}
else
{
Serial.print("Celcius: ");
float temperature = (voltage - .5) * 100;
Serial.print(temperature);
Serial.println(" degrees.");
delay(1000);
}
}
if (Serial.available()) {
// wait a bit for the entire message to arrive
delay(100);
// clear the screen
lcd.clear();
// read all the available characters
while (Serial.available() > 0) {
// display each character to the LCD
lcd.write(Serial.read());
}
}
}