#include <LiquidCrystal.h>
const int rs = 2, en = 3, d4 = 4, d5 = 5, d6 = 6, d7 = 7;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
#define SW0 digitalRead(8)
#define SW1 digitalRead(9)
#define SW2 digitalRead(10)
#define SW3 digitalRead(11)
int8_t menu;
bool latchSW0, latchSW1, latchSW2, latchSW3;
void setup() {
lcd.begin(16, 2);
pinMode(8, INPUT_PULLUP);
pinMode(9, INPUT_PULLUP);
pinMode(10, INPUT_PULLUP);
pinMode(11, INPUT_PULLUP);
}
void loop() {
if (menu==0){
lcd.setCursor(4, 0);
lcd.print("tekan SW0");
//p&r SW0//
if (latchSW0==0 && SW0==0){
latchSW0=1;
}
if (latchSW0==1 && SW0==1){
lcd.clear();
menu=1;
latchSW0=0;
}
//and p&r SW0//
}
if (menu==1){
lcd.setCursor(0, 0);
lcd.print(">ADC-A0");
lcd.setCursor(0, 1);
lcd.print(" ADC-A1");
//p&r SW3//
if (latchSW3==0 && SW3==0){
latchSW3=1;
}
if (latchSW3==1 && SW3==1){
lcd.clear();
menu=0;
latchSW3=0;
}
//and p&r SW3//
//p&r SW0//
if (latchSW0==0 && SW0==0){
latchSW0=1;
}
if (latchSW0==1 && SW0==1){
lcd.clear();
menu=3;
latchSW0=0;
}
//and p&r SW0//
//p&r SW1//
if (latchSW1==0 && SW1==0){
latchSW1=1;
}
if (latchSW1==1 && SW1==1){
lcd.clear();
menu=2;
latchSW1=0;
}
//and p&r SW1//
}
if (menu==2){
lcd.setCursor(0, 0);
lcd.print(" ADC-A0");
lcd.setCursor(0, 1);
lcd.print(">ADC-A1");
//p&r SW3//
if (latchSW3==0 && SW3==0){
latchSW3=1;
}
if (latchSW3==1 && SW3==1){
lcd.clear();
menu=0;
latchSW3=0;
}
//and p&r SW3//
//p&r SW2//
if (latchSW2==0 && SW2==0){
latchSW2=1;
}
if (latchSW2==1 && SW2==1){
lcd.clear();
menu=1;
latchSW2=0;
}
//and p&r SW2//
//p&r SW0//
if (latchSW0==0 && SW0==0){
latchSW0=1;
}
if (latchSW0==1 && SW0==1){
lcd.clear();
menu=4;
latchSW0=0;
}
//and p&r SW0//
}
if (menu==3){
lcd.setCursor(0, 0);
lcd.print("ADC-A0: ");
lcd.print(analogRead(A0));
lcd.print(" ");
//p&r SW3//
if (latchSW3==0 && SW3==0){
latchSW3=1;
}
if (latchSW3==1 && SW3==1){
lcd.clear();
menu=1;
latchSW3=0;
}
//and p&r SW3//
}
if (menu==4){
lcd.setCursor(0, 0);
lcd.print("ADC-A1: ");
lcd.print(analogRead(A1));
lcd.print(" ");
//p&r SW3//
if (latchSW3==0 && SW3==0){
latchSW3=1;
}
if (latchSW3==1 && SW3==1){
lcd.clear();
menu=2;
latchSW3=0;
}
//and p&r SW3//
}
}