Menu Control
Menu Control
Menu Control
// 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
// OBJECT DECLARATION
LiquidCrystal_I2C lcd(0x27, 16, 2); // Activates the LCD "object"
// SETUP
void setup() {
lcd.backlight(); // THESE COMMANDS TURN ON AND CLEAR THE LCD
SCREEN
lcd.init();
lcd.clear();
delay(1000);
// MAIN LOOP
void loop() {
// 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);
}
}
*/