#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
enum PlantType{
ROSE,
FICUS,
FERN,
ADS,
SDF,
ZZZ,
JJJ,
PPP,
END_OF_LIST };
PlantType plantType = ROSE;
char* plantString[] = {"T Type", "B Type", "E Type", "J Type", "K Type", "N Type", "R Type", "S Type"};
const byte buttonPin[] = {7};
void setup()
{
pinMode(7,INPUT_PULLUP);
lcd.init();
lcd.backlight();
lcd.setCursor(1, 0);
lcd.print("Select TC");
for(byte i = 0; i < sizeof(buttonPin); i++)
{
pinMode(buttonPin[i], INPUT_PULLUP);
}
}
void loop()
{
int buttonSelected = checkForPress();
switch(buttonSelected)
{
case 1:
plantType = PlantType(int(plantType)+1);
if(plantType == END_OF_LIST) plantType = ROSE; //<<< Edited here
lcd.setCursor(0, 0);
lcd.print(F("TC Setected:"));
lcd.setCursor(0, 1);
lcd.print(plantString[plantType]);
break;
}
delay(30); //crude de-bounce
}
int checkForPress()
{
static byte lastState[1] = {HIGH};
for(int i = 0; i < 1; i++)
{
byte state = digitalRead(buttonPin[i]);
if (state != lastState[i])
{
lastState[i] = state;
if(state == LOW)
{
return i + 1; //edit
}
}
}
return 0;
}