kontrol menu dan submenu pada aplikasi lcd arduino

anda mau bikin kontrol alat dengan bantuan tayangan menu pada lcd, berikut contoh ringannya yang dapat anda kembangkan.
sketch :
#include <LiquidCrystal.h>

LiquidCrystal lcd(7, 6, 9, 10, 11, 12);

const int sw1 = 2;
const int sw2 = 3;
const int sw3 = 4;
int ok = 0;
int up = 0;
int down = 0;
void setup() {

pinMode(sw1, INPUT_PULLUP);
pinMode(sw2, INPUT_PULLUP);
pinMode(sw3, INPUT_PULLUP);
//Serial.begin(9600);
lcd.begin(16, 2);
lcd.print("TEST PARTAI");
lcd.setCursor(0,1);
lcd.print("ucuf");
delay(2000);
lcd.clear();

}

void loop()
{

menu:
while(1)
{
lcd.clear();
lcd.setCursor(2,0);
lcd.print("partai");
lcd.setCursor(0,1);
lcd.print("warna identik");
delay(100);
readtomb();

if (ok == LOW) { delay(200); goto menu1; }
if (up == LOW) { }
if (down == LOW) { }
}

menu1:
while(1)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("1.Merah <");
lcd.setCursor(0,1);
lcd.print("2.kuning ");
delay(100);
readtomb();

if (ok == LOW) { delay(200); goto menupdi; }
if (up == LOW) {}
if (down == LOW) { delay(200); goto menu2; }

}
menu2:
while(1)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("2.kuning <");
lcd.setCursor(0,1);
lcd.print("3.biru ");
delay(100);

readtomb();

if (ok == LOW) { delay(200); goto menugolkar; }
if (up == LOW) {delay(200); goto menu1;}
if (down == LOW) { delay(200); goto menu3; }

}

menupdi:
while(1)
{

lcd.clear();
lcd.setCursor(0,0);
lcd.print("merah itu");
lcd.setCursor(0,1);
lcd.print("partai pdi");
delay(100);
readtomb();

if (ok == LOW) { goto menu;}
if (up== LOW) { }
if (down== LOW) { }

}

menugolkar:
while(1)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("kuning itu");
lcd.setCursor(0,1);
lcd.print("golkar");
delay(100);
readtomb();

if (ok == LOW) { delay(200); goto menu; }
if (up == LOW) {}
if (down == LOW) {}

}

menu3:
while(1)
{

lcd.clear();
lcd.setCursor(0,0);
lcd.print("2.Kuning");
lcd.setCursor(0,1);
lcd.print("3.Biru <");
delay(100);

readtomb();
if (ok == LOW) { delay(200); goto menusby;}
if (up == LOW) { delay(200); goto menu2;}
if (down == LOW) {}

}


menusby:
while(1)
{

lcd.clear();
lcd.setCursor(0,0);
lcd.print("biru itu");
lcd.setCursor(0,1);
lcd.print("demokrat");
delay(100);
readtomb();

if (ok == LOW) { delay(200); goto menu;}
if (up == LOW) { delay(200); goto menu3;}
if (down == LOW) {}

}}

int readtomb()
{
ok = digitalRead(sw1);
up = digitalRead(sw2);
down = digitalRead(sw3);}



Demikian tks. 

Komentar

Postingan Populer