Professional Documents
Culture Documents
Incubator Prototype
Incubator Prototype
// Temp/Humidity Sensor
//#include "Debounce.h"
/*#include "DHT.h"
// LCD
#include <Wire.h>
// MENU ARRAYS
String menuOption[] = {{"Setting 1"}, {"Setting 2"}, {"Setting 3"}}; //
Text on the top line
String measurementType[] = {{"[DEG. CEL]"}, {"HUMIDITY"}, {"DAYS"}}; // Text on
the bottom line
// Temp/Humidity Sensor
#define DHTPIN 2 // what pin we're connected to
#define DHTTYPE DHT22 // DHT 22 (AM2302)
// Initialize DHT sensor for normal 16mhz Arduino
DHT dht(DHTPIN, DHTTYPE);
// PINS ON THE ARDUINO.
// MAKE THESE "CONST INT" VARIABLES AS THESE DO NOT CHANGE IN THE PROGRAM.
const int leftButtonPin = 5; // Pin 5 for "Left" command
const int rightButtonPin = 6; // Pin 6 for "Right" command
const int upButtonPin = 7; // Pin 7 for "Up" command
const int downButtonPin = 8; // Pin 8 for "Down" command
const int enterButtonPin = 9; // Pin 9 for "Enter" command
const int clearButtonPin = 10; // Pin 10 for "Clear" command
// OBJECT DECLARATION
//LiquidCrystal_I2C lcd(0x27, 16, 2); // Activates the LCD "object"
// LCD
//Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();
// Relay
#define RELAYPIN 3
void setup() {
Serial.begin(9600);
delay(1000);
// Setup relay
pinMode(RELAYPIN, OUTPUT);
}
void loop() {
int unitSetting[] = {setting1Counter, setting2Counter, setting3Counter}; //
This variable holds the individual counters in one array
// The current state for each button is set not equal to the pressed state
and when it changes, the pressed state becomes equal to the current state.
if (buttonStateRight == LOW)
{
directionPush++; // Both the up and down
press counts will be reset to zero when the right button is pushed.
upPressCount = 0;
downPressCount = 0;
}
// UP BUTTON PRESS
if (currentButtonStateUp != buttonStateUp) // Up button scrolls the
setting upward.
{
buttonStateUp = currentButtonStateUp;
{
upPressCount++;
downPressCount = 0; // The downPressCount is
reset to zero.
setting1Counter++;
if (upPressCount > 5)
{
setting2Counter = setting2Counter + 4;
}
if (upPressCount > 5)
{
setting3Counter = setting3Counter + 4;
}
if (downPressCount > 5)
{
setting2Counter = setting2Counter - 4;
}
if (downPressCount > 5)
{
setting3Counter = setting3Counter - 4;
}
lcd.clear();
}
lcd.clear();
lcd.setCursor(0,0);
lcd.print("HUMIDITY");
lcd.setCursor(0,1);
lcd.print("IS SET");
delay(2000);
{ // It flahses a brief
message stating that the data has been cleared.
lcd.clear(); // The press counts
for both the up and down variables are also reset to zero.
lcd.setCursor(0,0);
lcd.print("TEMPERATURE");
lcd.setCursor(0,1);
lcd.print("IS CLEARED");
setting1Counter = 0;
downPressCount = 0;
upPressCount = 0;
delay(2000);
}
if (buttonStateClear == LOW && directionPush == 1)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("HUMIDITY");
lcd.setCursor(0,1);
lcd.print("IS CLEARED");
setting2Counter = 0;
downPressCount = 0;
upPressCount = 0;
delay(2000);
}
// Check if any reads failed and exit early (to try again).
if (isnan(humidity) || isnan(temp)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
lcd.setCursor(0,0);
lcd.print("H: ");
lcd.print(humidity);
lcd.print(" % ");
lcd.setCursor(0,1);
lcd.print("T: ");
lcd.print(temp);
lcd.print(" F ");
}
//Updates the delay variable
previousMillis = currentMillis;
}*/