Code:

#include <DHT.h>

#include <DHT_U.h>

 

// 1.) What is the difference between a DHT11 and a DHT21 sensor?

//Characteristics that differ from each sensor includes:

// - Size

// - Color

// - DHT11 reads more accurately

// - DH11 faster with measurements

// - DH22 reads a wider range of temperatures

 

// 2.) What is a Thermistor?

//A resistor that changes its resistance with temperature.

 

// 3.) Name all available pins that you can use on the wire shield when the LCD screen is attached.

// The avaliable digital pins include: 0, 1, 2, 3, 11, 12 and 13. 

// Analog pins include: 1, 2, 3, 4 and 5

// Power pins include GND and 5v

 

//------------------------------------------------------------------------------------------------

//------------------------------------------------------------------------------------------------

//------------------------------------------------------------------------------------------------

//------------------------------------------------------------------------------------------------

//------------------------------------------------------------------------------------------------

//------------------------------------------------------------------------------------------------

#include <LiquidCrystal.h>

 

#include <DHT.h>

#include <DHT_U.h>

#include <Adafruit_Sensor.h>

 

#include "DHT.h"

 

#define DHTPIN 2     // what digital pin we're connected to

 

#define DHTTYPE DHT11   // DHT 11

 

DHT dht(DHTPIN, DHTTYPE);

 

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

// define some values used by the panel and buttons

int lcd_key     = 0;

int adc_key_in  = 0;

#define btnRIGHT  0

#define btnUP     1

#define btnDOWN   2

#define btnLEFT   3

#define btnSELECT 4

#define btnNONE   5

int photocellPin = 1;     // the cell and 10K pulldown are connected to a0

int photocellReading;  

int buttonPressed;

int currentBtn = 1;

 

  float h = dht.readHumidity();

  float t = dht.readTemperature();

  float f = dht.readTemperature(true);

 

 

 

  float hif = dht.computeHeatIndex(f, h);

  float hic = dht.computeHeatIndex(t, h, false);

 

 

int ReadButtonInput(int temp){

  

 adc_key_in = analogRead(0);      // read the value from the sensor 

 // my buttons when read are centered at these valies: 0, 144, 329, 504, 741

 // we add approx 50 to those values and check to see if we are close

 lcd.clear();

 if (adc_key_in < 50)   return btnRIGHT;  

 if (adc_key_in < 195)  return btnUP; 

 if (adc_key_in < 380)  return btnDOWN; 

 if (adc_key_in < 555)  return btnLEFT; 

 if (adc_key_in < 790)  return btnSELECT;

 return temp;

}

 

void setup() {

  lcd.begin(16, 2);              // start the library

  lcd.setCursor(0,0);

  dht.begin();

  lcd.print("Welcome!");

  lcd.setCursor(0,1);

  lcd.print("Make a selection");

  delay(2000);

  lcd.clear();

  lcd.setCursor(0,0);

}

 

void loop() {

 

 

  lcd.setCursor(0,1);            // move to the begining of the second line

  lcd_key = ReadButtonInput(currentBtn);

 // lcd.clear();

  lcd.setCursor(0,0);

  lcd.print(lcd_key);

  for (int i = 0; i < 20; i++)

  {

     switch (lcd_key)               // depending on which button was pushed, we perform an action

 {

   case btnRIGHT:

     {

     // lcd.clear();

      lcd.setCursor(0,0);

      lcd.print("Temperature:");

      lcd.setCursor(0,1);

      lcd.print("Kelvin:");

      lcd.setCursor(10,1);

      lcd.print(dht.readTemperature() +  273.15); // none (c) celsius

      //lcd.clear();

      currentBtn = lcd_key;

     break;

     }

   case btnLEFT:

     {

      //lcd.clear();

      lcd.setCursor(0,0);

      lcd.print("Temperature:");

      lcd.setCursor(0,1);

      lcd.print("Humidity:");

      lcd.setCursor(10,1);

      lcd.print(dht.readHumidity());

      //lcd.clear();

      currentBtn = lcd_key;

     break;

     }

   case btnUP:

     {

     // lcd.clear();

      lcd.setCursor(0,0);

      lcd.print("Temperature:");

      lcd.setCursor(0,1);

      lcd.print("Fahrenheit:");

      lcd.setCursor(11,1);

      lcd.print(dht.readTemperature(true)); // true (f) farenheight 

      currentBtn = lcd_key;

     break;

     }

   case btnDOWN:

     {

     // lcd.clear();

      lcd.setCursor(0,0);

      lcd.print("Temperature:");

      lcd.setCursor(0,1);

      lcd.print("Celsius:");

      lcd.setCursor(10,1);

      lcd.print(dht.readTemperature()); // none (c) celsius

      currentBtn = lcd_key;

     break;

     }

   case btnSELECT:

     {

      photocellReading = analogRead(photocellPin);  

      //lcd.clear();

      lcd.setCursor(0,0);

      lcd.print("Light:");

      lcd.setCursor(0,1);

      lcd.print("Intensity:");

      lcd.setCursor(10,1);

      photocellReading = analogRead(photocellPin);  

      lcd.print(photocellReading);     // the raw analog rea

      currentBtn = lcd_key;

     break;

     }

   }

  }

 

 

}