I wrote a small code where pressing a button changes a variable...
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 10, 9);
int switchPin = 19; // momentary switch on A5, other side connected to ground
int mode = 0;
int prevstate = HIGH;
int currstate;
void setup()
{
lcd.begin(16, 2);
pinMode(switchPin, INPUT);
digitalWrite(switchPin, HIGH); // turn on pullup resistor
}
void loop()
{
currstate = digitalRead(switchPin);
if ((currstate != prevstate) && currstate == HIGH){
lcd.clear();
mode = mode + 1;
if(mode > 3){
mode = 1;
}
}
switch (mode) {
case 1: {
lcd.setCursor(0, 0);
lcd.print("MODE 1"); // first part of mode 1
lcd.setCursor(0, 1);
lcd.print("A"); // second part of mode 1
break;
}
case 2: {
lcd.setCursor(0, 0);
lcd.print("MODE 2"); // first part of mode 1
lcd.setCursor(0, 1);
lcd.print("A"); // second part of mode 1
break;
}
case 3: {
lcd.setCursor(0, 0);
lcd.print("MODE 3"); // first part of mode 1
lcd.setCursor(0, 1);
lcd.print("A"); // second part of mode 1
break;
}
}
prevstate = currstate;
}
Now I would like to include a second button to the code and do things like
if MODE is 1 or 2 or 4 and the second button is pressed short change the second part in the MODES from A to B, or B to C, or C to D
Long pressing of button 1 will blink the current second part of the MODE and then
long pressing of the second button will reset the value of the blinking part ( where all A, B, C & D has a dynamic value)
How do I do this...??