// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

const int tempPin = A1;
const int lRes = A5;

void setup() 
{
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("Temp is ");
  pinMode (tempPin, INPUT);
  //pinMode(lRes, INPUT);
  Serial.begin(9600); 
}

void loop() 
{
  //get the voltage reading from the analoge pin
  int tempReading = analogRead(tempPin);
  //convert the tempReading to volts
  float tempVoltage = tempReading * 5.0;
  tempVoltage /= 1024;
  //print out voltage
  //Serial.print(tempVoltage); Serial.println(" Volts");
  //display temp in c
  float tempC = (tempVoltage - 0.5) * 100;
  lcd.setCursor(0, 0);
  // Print a message to the LCD.
  lcd.print("Temp is ");
  lcd.setCursor(8,0);
  lcd.print(tempC); lcd.print(" C");
  //Serial.print ("Temprature is "); Serial.println(tempC);
  delay (50);
  
  int val = analogRead(lRes);
  val = constrain (val, 0, 1024);
  int lightVal = map((val), 0, 1024, 100, 0);
  Serial.println(lightVal);
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  
  if (lightVal < 10)
  {
  //Serial.println(lightVal);
  //Serial.print("Light level "); Serial.println(val);
  lcd.print("Light "); lcd.print(lightVal); lcd.print(" ");
  delay (50);
  }
  
  else
  {
  lcd.print("Light "); lcd.print(lightVal);
  delay (50);
  }
}