#include <LiquidCrystal_I2C.h>
#include <Wire.h>

#define TK 5
#define TOK 4
#define TUP 2
#define TDOWN 3
#define Tekan LOW
#define waktu 100
#define lama 250
#define phi 3,14

const int minpersegi = 0;   
const int minppanjang = 0;
const int minphytagoras = 0;
const int minlingkaran = 0;
const int minsegitiga = 0;

const int maxpersegi = 25; 
const int maxppanjang = 25;
const int maxphytagoras = 25;
const int maxlingkaran = 25;
const int maxsegitiga = 25;

// value persegi
int valuepersegi = 0 ;

// value persegi panjang
int valuep = 0;
int valuel = 0;

// phytagoras
int valuea = 0;
int valueb = 0;
int valuec = 0;

// lingkaran
int valueR = 0;
// segitga 
int valuesegitiga1 = 0;
int valuesegitiga2 = 0;

int penampungpersegipanjang = 0;
int penumpangpersegi = 0;
int penampungphytagoras = 0;
int penampunglingkaran = 0;
int penampungA = 0; 
int penampungB = 0; 
int penampungC = 0;
int penampungsegitiga = 0; 

LiquidCrystal_I2C lcd ( 0x27 , 20, 4);

// tampilan bangun datar 
// kiri atas
byte siku1[8] = {
  B11111,
  B10000,
  B10000,
  B10000,
  B10000,
  B10000,
  B10000,
  B10000

};

byte siku2[8] = {
  B10000,
  B10000,
  B10000,
  B10000,
  B10000,
  B10000,
  B10000,
  B11111
};

byte siku3[8] = {
  B11111,
  B00001,
  B00001,
  B00001,
  B00001,
  B00001,
  B00001,
  B00001
};

byte siku4[8] = {
  B00001,
  B00001,
  B00001,
  B00001,
  B00001,
  B00001,
  B00001,
  B11111
};

byte datar1[8] = {
  B11111,
  B00000,
  B00000,
  B00000,
  B00000,
  B00000,
  B00000,
  B00000
};

byte datar2[8] = {
  B00000,
  B00000,
  B00000,
  B00000,
  B00000,
  B00000,
  B00000,
  B11111
};

byte s[8] = {
  B00000,
  B01110,
  B01000,
  B01110,
  B00010,
  B01110,
  B00000,
  B00000
};

byte P[8] = {
  B00000,
  B01110,
  B01001,
  B01001,
  B01110,
  B01000,
  B01000,
  B00000
};

byte L[8] = {
  B00000,
  B01000,
  B01000,
  B01000,
  B01000,
  B01111,
  B00000,
  B00000
};

byte datarbawah[8] = {
  B11000,
  B10100,
  B10010,
  B10001,
  B10000,
  B10000,
  B10000,
  B10000
};

byte menurun1[8] = {
  B00000,
  B00000,
  B00000,
  B00000,
  B00000,
  B10000,
  B01000,
  B00100
};

byte menurun2[8] = {
  B00010,
  B00001,
  B00000,
  B00000,
  B00000,
  B00000,
  B00000,
  B11111
};

byte menurun3[8] = {
  B00000,
  B00000,
  B00000,
  B10000,
  B01000,
  B00100,
  B00010,
  B11111
};

byte a[8] = {
  B00000,
  B01110,
  B01010,
  B01010,
  B01110,
  B01010,
  B00000,
  B00000
};

byte b[8] = {
  B00000,
  B01110,
  B01001,
  B01110,
  B01001,
  B01110,
  B00000,
  B00000
};

byte c[8] = {
  B00000,
  B00000,
  B00110,
  B01000,
  B01000,
  B00110,
  B00000,
  B00000
};

byte dua[8]{
 B11110,
 B00010,
 B11110,
 B10000,
 B11110,
 B00000,
 B00000,
 B00000
};


void setup() {
lcd.init ();
lcd.backlight();
lcd.begin (20,4);

pinMode (TK ,INPUT_PULLUP);
pinMode (TOK ,INPUT_PULLUP);
pinMode (TUP ,INPUT_PULLUP);
pinMode (TDOWN ,INPUT_PULLUP);

}

void loop() {


setmenu1:
   if (digitalRead(TOK) == Tekan){
    delay(waktu);
    while (digitalRead(TOK) == Tekan) {}
    lcd.clear();
    // goto pindah 
    // goto bangun ruang;
    goto menupilihan;
   } else if (digitalRead(TUP) == Tekan){
    delay(waktu);
    while (digitalRead(TUP) == Tekan){}
    lcd.clear();
    goto setmenu3;
   } else if (digitalRead(TDOWN) == Tekan){
    delay(waktu);
    while (digitalRead(TDOWN) == Tekan){}
    lcd.clear();
    goto setmenu2;
   }

   lcd.setCursor(0,0);
   lcd.print(">BANGUN DATAR");
   lcd.setCursor(0,1);
   lcd.print(" TRIGONOMETRI");
   lcd.setCursor(0,2);
   lcd.print(" PHYTAGORAS");

goto setmenu1;

// setmenu 2
setmenu2:
   if (digitalRead(TOK) == Tekan){
    delay(waktu);
    while (digitalRead(TOK) == Tekan) {}
    lcd.clear();
    goto menusin1;
   } else if (digitalRead(TUP) == Tekan){
    delay(waktu);
    while (digitalRead(TUP) == Tekan){}
    lcd.clear();
    goto setmenu1;
   } else if (digitalRead(TDOWN) == Tekan){
    delay(waktu);
    while (digitalRead(TDOWN) == Tekan){}
    lcd.clear();
    goto setmenu3;
   }

   lcd.setCursor(0,0);
   lcd.print(" BANGUN DATAR");
   lcd.setCursor(0,1);
   lcd.print(">TRIGONOMETRI");
   lcd.setCursor(0,2);
   lcd.print(" PHYTAGORAS");

goto setmenu2;


// setmenu 3
setmenu3:
   if (digitalRead(TOK) == Tekan){
    delay(waktu);
    while (digitalRead(TOK) == Tekan) {}
    lcd.clear();
    goto nilaiA;
   } else if (digitalRead(TUP) == Tekan){
    delay(waktu);
    while (digitalRead(TUP) == Tekan){}
    lcd.clear();
    goto setmenu2;
   } else if (digitalRead(TDOWN) == Tekan){
    delay(waktu);
    while (digitalRead(TDOWN) == Tekan){}
    lcd.clear();
    goto setmenu1;
   }

   lcd.setCursor(0,0);
   lcd.print(" BANGUN DATAR");
   lcd.setCursor(0,1);
   lcd.print(" TRIGONOMETRI");
   lcd.setCursor(0,2);
   lcd.print(">PHYTAGORAS");

goto setmenu3;
// pilih //====================================
menupilihan:

// setpersegi
setpersegi:
   if (digitalRead(TOK) == Tekan){
    delay(waktu);
    while (digitalRead(TOK) == Tekan) {}
    lcd.clear();
    goto persegi;
   } else if (digitalRead(TUP) == Tekan){
    delay(waktu);
    while (digitalRead(TUP) == Tekan){}
    lcd.clear();
    goto setsegitiga;
   } else if (digitalRead(TDOWN) == Tekan){
    delay(waktu);
    while (digitalRead(TDOWN) == Tekan){}
    lcd.clear();
    goto setpersegipanjang;
   }else if (digitalRead(TK) == Tekan){
    delay(waktu);
    while (digitalRead(TK) == Tekan);
    lcd.clear();
    goto setmenu1;
   }

lcd.setCursor(0,0);
lcd.print(">PERSEGI");
lcd.setCursor(0,1);
lcd.print(" PERSEGI PANJANG");
lcd.setCursor(0,2);
lcd.print(" LINGKARAN");
lcd.setCursor(0,3);
lcd.print(" BELAH KETUPAT");
goto setpersegi;

// setpersegipanjang
setpersegipanjang:
   if (digitalRead(TOK) == Tekan){
    delay(waktu);
    while (digitalRead(TOK) == Tekan) {}
    lcd.clear();
    goto setmenupersegipanjang1;
   } else if (digitalRead(TUP) == Tekan){
    delay(waktu);
    while (digitalRead(TUP) == Tekan){}
    lcd.clear();
    goto setpersegi;
   } else if (digitalRead(TDOWN) == Tekan){
    delay(waktu);
    while (digitalRead(TDOWN) == Tekan){}
    lcd.clear();
    goto setlingkaran;
   } else if (digitalRead(TK) == Tekan){
    delay(waktu);
    while (digitalRead(TK) == Tekan);
    lcd.clear();
    goto setmenu1;
   }

lcd.setCursor(0,0);
lcd.print(" PERSEGI");
lcd.setCursor(0,1);
lcd.print(">PERSEGI PANJANG");
lcd.setCursor(0,2);
lcd.print(" LINGKARAN");
lcd.setCursor(0,3);
lcd.print(" BELAH KETUPAT");

goto setpersegipanjang;

// Lingkaran
setlingkaran:
   if (digitalRead(TOK) == Tekan){
    delay(waktu);
    while (digitalRead(TOK) == Tekan) {}
    lcd.clear();
    goto setpilihlingkaran;
   } else if (digitalRead(TUP) == Tekan){
    delay(waktu);
    while (digitalRead(TUP) == Tekan){}
    lcd.clear();
    goto setpersegipanjang;
   } else if (digitalRead(TDOWN) == Tekan){
    delay(waktu);
    while (digitalRead(TDOWN) == Tekan){}
    lcd.clear();
    goto setsegitiga;
   } else if (digitalRead(TK) == Tekan){
    delay(waktu);
    while (digitalRead(TK) == Tekan);
    lcd.clear();
    goto setmenu1;
   }

lcd.setCursor(0,0);
lcd.print(" PERSEGI");
lcd.setCursor(0,1);
lcd.print(" PERSEGI PANJANG");
lcd.setCursor(0,2);
lcd.print(">LINGKARAN");
lcd.setCursor(0,3);
lcd.print(" BELAH KETUPAT");

goto setlingkaran;

// Segitiga
setsegitiga:
   if (digitalRead(TOK) == Tekan){
    delay(waktu);
    while (digitalRead(TOK) == Tekan) {}
    lcd.clear();
    goto setpilihsegitiga;
   } else if (digitalRead(TUP) == Tekan){
    delay(waktu);
    while (digitalRead(TUP) == Tekan){}
    lcd.clear();
    goto setlingkaran;
   } else if (digitalRead(TDOWN) == Tekan){
    delay(waktu);
    while (digitalRead(TDOWN) == Tekan){}
    lcd.clear();
    goto setpersegi;
   } else if (digitalRead(TK) == Tekan){
    delay(waktu);
    while (digitalRead(TK) == Tekan);
    lcd.clear();
    goto setmenu1;
   }

lcd.setCursor(0,0);
lcd.print(" PERSEGI");
lcd.setCursor(0,1);
lcd.print(" PERSEGI PANJANG");
lcd.setCursor(0,2);
lcd.print(" LINGKARAN");
lcd.setCursor(0,3);
lcd.print(">BELAH KETUPAT");

goto setsegitiga;
goto menupilihan;

persegi:

lcd.createChar(0, siku1);
lcd.createChar(1, siku2);
lcd.createChar(2, siku3);
lcd.createChar(3, siku4);
lcd.createChar(4, datar1);
lcd.createChar(5, datar2);
lcd.createChar(6, s);
lcd.createChar(7,dua);

  lcd.setCursor(2, 1); 
  lcd.write((uint8_t)0);
  lcd.setCursor(2, 2); 
  lcd.write(uint8_t(1));

  lcd.setCursor(3, 1); 
  lcd.write((uint8_t)4);
  lcd.setCursor(3, 2); 
  lcd.write((uint8_t)5);

  lcd.setCursor(4,1);
  lcd.write((uint8_t)2);
  lcd.setCursor(4,2);
  lcd.write((uint8_t)3);

  // tampilan kata
  lcd.setCursor(3,0);
  lcd.write((uint8_t)6);
  lcd.setCursor(3,3);
  lcd.write((uint8_t)6);
  lcd.setCursor(1,1);
  lcd.write((uint8_t)6);
  lcd.setCursor(5,2);
  lcd.write(uint8_t(6));


  if (digitalRead(TUP) == Tekan && valuepersegi < maxpersegi){
    valuepersegi++;
    delay(lama);
   } else if (digitalRead(TDOWN) == Tekan && valuepersegi > minpersegi ){
    valuepersegi--;
    delay(lama);
   }

   if (digitalRead(TOK) == Tekan){
    delay(waktu);
    while(digitalRead(TOK) == Tekan){}
    lcd.clear();
    penumpangpersegi = (4 * valuepersegi) ;
    lcd.setCursor(7,2);
    lcd.print("4 * S :");
    lcd.print((penumpangpersegi < 10? "0" : "") + String (penumpangpersegi));
    lcd.print("cm");
    lcd.write(uint8_t(7)); 
   } else if (digitalRead(TK) == Tekan){
    delay(waktu);
    while(digitalRead(TK) == Tekan){}
    lcd.clear();
    valuepersegi = 0;
    goto setpersegi;
   }
    lcd.setCursor(7,1);
    lcd.print("SISI  :");
    lcd.print((valuepersegi < 10? "0" : "") + String (valuepersegi)); 
    lcd.setCursor(7,2);
    lcd.print("4 * S :");

goto persegi;


setmenupersegipanjang1:

if(digitalRead(TUP) == Tekan){
  delay(waktu);
  while(digitalRead(TUP) == Tekan){}
  lcd.clear();
  goto setmenupersegipanjang2;
} else if (digitalRead(TDOWN) == Tekan){
  delay(waktu);
  while (digitalRead(TDOWN) == Tekan){}
  lcd.clear();
  goto setmenupersegipanjang2;
}else if (digitalRead(TOK) == Tekan){
  delay(waktu);
  while(digitalRead(TOK) == Tekan){}
  lcd.clear();
  goto luaspersegipanjang;
} else if (digitalRead(TK) == Tekan){
  delay(waktu);
  while (digitalRead(TK) == Tekan){}
  lcd.clear();
 goto setpersegipanjang;
}

lcd.setCursor(0,0);
lcd.print(">LUAS");
lcd.setCursor(0,1);
lcd.print(" KELILING");

goto setmenupersegipanjang1;

setmenupersegipanjang2:

 if (digitalRead(TUP) == Tekan){
  delay(waktu);
  while(digitalRead(TUP) == Tekan){}
  lcd.clear();
  goto setmenupersegipanjang1;
} else if(digitalRead(TDOWN) == Tekan){
  delay(waktu);
  while(digitalRead(TDOWN) == Tekan){}
  lcd.clear();
  goto setmenupersegipanjang1;
} else if (digitalRead(TOK) == Tekan){
  delay(waktu);
  while(digitalRead(TOK) == Tekan){}
  lcd.clear();
 goto kelilingpersegipanjang;
} else if (digitalRead(TK) == Tekan){
  delay(waktu);
  while (digitalRead(TK) == Tekan){}
  lcd.clear();
 goto setpersegipanjang;
}
lcd.setCursor(0,0);
lcd.print(" LUAS");
lcd.setCursor(0,1);
lcd.print(">KELILING");

goto setmenupersegipanjang2;

luaspersegipanjang:

  lcd.createChar(1,siku1);
  lcd.createChar(2,siku2);
  lcd.createChar(3,datar1);
  lcd.createChar(4,siku3);
  lcd.createChar(5,siku4);
  lcd.createChar(6,datar2);
  lcd.createChar(7,P);
  lcd.createChar(8,L);

  lcd.setCursor(2, 1); 
  lcd.write((uint8_t)1);
  lcd.setCursor(2,2);
  lcd.write((uint8_t)2);
  lcd.setCursor(3,1);
  lcd.write((uint8_t)3);
  lcd.setCursor(4,1);
  lcd.write((uint8_t)3);
  lcd.setCursor(5,1);
  lcd.write((uint8_t)3);
  lcd.setCursor(6,1);
  lcd.write((uint8_t)3);
  lcd.setCursor(7,1);
  lcd.write((uint8_t)4);
  lcd.setCursor(7,2);
  lcd.write((uint8_t)5);
  lcd.setCursor(3,2);
  lcd.write((uint8_t)6);
  lcd.setCursor(4,2);
  lcd.write((uint8_t)6);
  lcd.setCursor(5,2);
  lcd.write((uint8_t)6);
  lcd.setCursor(6,2);
  lcd.write((uint8_t)6);

  lcd.setCursor(4,0);
  lcd.write((uint8_t)7);
  lcd.setCursor(1,2);
  lcd.write((uint8_t)8);

goto P;


goto luaspersegipanjang;

P:

if (digitalRead(TUP) == Tekan && valuep < maxppanjang ){
  valuep++;
  delay(lama);
} else if (digitalRead(TDOWN) == Tekan && valuep > minppanjang){
  valuep--;
  delay(lama);
} else if (digitalRead(TOK) == Tekan) {
  delay(waktu);
  while (digitalRead(TOK) == Tekan){}
  goto L;
} else if (digitalRead(TK) == Tekan){
  delay(waktu);
  while (digitalRead(TK) == Tekan){}
  lcd.clear();
  valuep = 0;
  valuel = 0;
  goto setmenupersegipanjang1;
}

lcd.setCursor(12,1);
lcd.print("P:");
lcd.print((valuep < 10? "0" : "") + String (valuep)); 

lcd.setCursor(12,2);
lcd.print("L:");
lcd.print((valuel < 10? "0" : "") + String (valuel)); 

  lcd.setCursor(10,3);
  lcd.print("P*L:");
 
goto P;

L:
if (digitalRead(TUP) == Tekan && valuel < maxppanjang ){
  valuel++;
  delay(lama);
 } else if (digitalRead(TDOWN) == Tekan && valuel > minppanjang){
  valuel--;
  delay(lama);
} else if (digitalRead(TOK) == Tekan) {
  delay(waktu);
  while (digitalRead(TOK) == Tekan){}
  lcd.clear();
  goto HASILPP;
} else if (digitalRead(TK) == Tekan){
  delay(waktu);
  while (digitalRead(TK) == Tekan){}
  lcd.clear();
  valuep = 0;
  valuel = 0;
  goto setmenupersegipanjang1;
}  

lcd.setCursor(12,1);
lcd.print("P:");
lcd.print((valuep < 10? "0" : "") + String (valuep)); 

lcd.setCursor(12,2);
lcd.print("L:");
lcd.print((valuel < 10? "0" : "") + String (valuel)); 

lcd.setCursor(10,3);
lcd.print("P*L:");
  
goto L;

HASILPP:

  penampungpersegipanjang = (valuep * valuel);
  
  lcd.setCursor(10,3);
  lcd.print("P*L:");
  lcd.print((penampungpersegipanjang < 10? "0" : "") + String (penampungpersegipanjang)); 
  lcd.print("cm");
goto luaspersegipanjang;
goto HASILPP;

// keliling ============================================
kelilingpersegipanjang:

  lcd.createChar(1,siku1);
  lcd.createChar(2,siku2);
  lcd.createChar(3,datar1);
  lcd.createChar(4,siku3);
  lcd.createChar(5,siku4);
  lcd.createChar(6,datar2);
  lcd.createChar(7,P);
  lcd.createChar(8,L);

  lcd.setCursor(2, 1); 
  lcd.write((uint8_t)1);
  lcd.setCursor(2,2);
  lcd.write((uint8_t)2);
  lcd.setCursor(3,1);
  lcd.write((uint8_t)3);
  lcd.setCursor(4,1);
  lcd.write((uint8_t)3);
  lcd.setCursor(5,1);
  lcd.write((uint8_t)3);
  lcd.setCursor(6,1);
  lcd.write((uint8_t)3);
  lcd.setCursor(7,1);
  lcd.write((uint8_t)4);
  lcd.setCursor(7,2);
  lcd.write((uint8_t)5);
  lcd.setCursor(3,2);
  lcd.write((uint8_t)6);
  lcd.setCursor(4,2);
  lcd.write((uint8_t)6);
  lcd.setCursor(5,2);
  lcd.write((uint8_t)6);
  lcd.setCursor(6,2);
  lcd.write((uint8_t)6);

  lcd.setCursor(4,0);
  lcd.write((uint8_t)7);
  lcd.setCursor(1,2);
  lcd.write((uint8_t)8);

goto P1;

goto kelilingpersegipanjang;

P1:

if (digitalRead(TUP) == Tekan && valuep < maxppanjang ){
  valuep++;
  delay(lama);
} else if (digitalRead(TDOWN) == Tekan && valuep > minppanjang){
  valuep--;
  delay(lama);
} else if (digitalRead(TOK) == Tekan) {
  delay(waktu);
  while (digitalRead(TOK) == Tekan){}
  goto L1;
} else if (digitalRead(TK) == Tekan){
  delay(waktu);
  while (digitalRead(TK) == Tekan){}
  lcd.clear();
  valuep = 0;
  valuel = 0;
  goto setmenupersegipanjang2;
}

lcd.setCursor(13,1);
lcd.print("P:");
lcd.print((valuep < 10? "0" : "") + String (valuep)); 

lcd.setCursor(13,2);
lcd.print("L:");
lcd.print((valuel < 10? "0" : "") + String (valuel)); 

  lcd.setCursor(8,3);
  lcd.print("2(P+L):");
 
goto P1;

L1:
if (digitalRead(TUP) == Tekan && valuel < maxppanjang ){
  valuel++;
  delay(lama);
 } else if (digitalRead(TDOWN) == Tekan && valuel > minppanjang){
  valuel--;
  delay(lama);
} else if (digitalRead(TOK) == Tekan) {
  delay(waktu);
  while (digitalRead(TOK) == Tekan){}
  lcd.clear();
  goto HASILPPK;
} else if (digitalRead(TK) == Tekan){
  delay(waktu);
  while (digitalRead(TK) == Tekan){}
  lcd.clear();
  penampungpersegipanjang = 0;
  valuep = 0;
  valuel = 0;

  goto setmenupersegipanjang2;
}  

lcd.setCursor(13,1);
lcd.print("P:");
lcd.print((valuep < 10? "0" : "") + String (valuep)); 

lcd.setCursor(13,2);
lcd.print("L:");
lcd.print((valuel < 10? "0" : "") + String (valuel)); 

lcd.setCursor(8,3);
lcd.print("2(P+L):");

goto L1;

HASILPPK:

  penampungpersegipanjang = 2 * (valuep + valuel);
  
  lcd.setCursor(8,3);
  lcd.print("2(P+L):");
  lcd.print((penampungpersegipanjang < 10? "0" : "") + String (penampungpersegipanjang)); 
  lcd.print("cm");
goto kelilingpersegipanjang;
goto HASILPPK;

setpilihlingkaran:
setpilihlingkaran1:
 if (digitalRead(TUP) == Tekan){
  delay(waktu);
  while(digitalRead(TUP) == Tekan){}
  lcd.clear();
  goto setpilihlingkaran2;
} else if(digitalRead(TDOWN) == Tekan){
  delay(waktu);
  while(digitalRead(TDOWN) == Tekan){}
  lcd.clear();
  goto setpilihlingkaran2;
} else if (digitalRead(TOK) == Tekan){
  delay(waktu);
  while(digitalRead(TOK) == Tekan){}
  lcd.clear();
 goto luaslingkaran;
} else if (digitalRead(TK) == Tekan){
  delay(waktu);
  while (digitalRead(TK) == Tekan){}
  lcd.clear();
 goto setlingkaran;
}
lcd.setCursor(0,0);
lcd.print(">LUAS");
lcd.setCursor(0,1);
lcd.print(" KELILING");
goto setpilihlingkaran1;

setpilihlingkaran2:

 if (digitalRead(TUP) == Tekan){
  delay(waktu);
  while(digitalRead(TUP) == Tekan){}
  lcd.clear();
  goto setpilihlingkaran;
} else if(digitalRead(TDOWN) == Tekan){
  delay(waktu);
  while(digitalRead(TDOWN) == Tekan){}
  lcd.clear();
  goto setpilihlingkaran;
} else if (digitalRead(TOK) == Tekan){
  delay(waktu);
  while(digitalRead(TOK) == Tekan){}
  lcd.clear();
 goto kelilinglingkaran;
} else if (digitalRead(TK) == Tekan){
  delay(waktu);
  while (digitalRead(TK) == Tekan){}
  lcd.clear();
 goto setlingkaran;
}
lcd.setCursor(0,0);
lcd.print(" LUAS");
lcd.setCursor(0,1);
lcd.print(">KELILING");

goto setpilihlingkaran2;
goto setpilihlingkaran;

luaslingkaran:

lcd.createChar(1,dua);

if (digitalRead(TUP) == Tekan && valueR < maxlingkaran ){
  valueR++;
  delay(lama);
} else if (digitalRead(TDOWN) == Tekan && valueR > minlingkaran){
  valueR--;
  delay(lama);
} else if (digitalRead(TOK) == Tekan) {
  delay(waktu);
  while (digitalRead(TOK) == Tekan){}
  lcd.clear();
  goto Hasilluaslingkaran;
} else if (digitalRead(TK) == Tekan){
  delay(waktu);
  while (digitalRead(TK) == Tekan){}
  lcd.clear();
  valueR = 0;
  goto setpilihlingkaran;
}

lcd.setCursor(2,1);
lcd.print("r : ");
lcd.print((valueR < 10? "0" : "") + String (valueR)); 

lcd.setCursor(2,2);
lcd.print("Phi * r");

lcd.setCursor(9, 2); 
lcd.write((uint8_t)1);
lcd.print(":");

goto luaslingkaran;

Hasilluaslingkaran:

if (valueR % 7 == 0) {
  float penampunglingkaran = static_cast<float>((valueR * valueR) * 22 ) / 7;
  if (penampunglingkaran == (int) penampunglingkaran) {
    lcd.setCursor(2,2);
    lcd.print("Phi * r");

    lcd.setCursor(9, 2); 
    lcd.write((uint8_t)1);
    lcd.print(":");  
    lcd.print(((int)penampunglingkaran < 10? "0" : "") + String ((int)penampunglingkaran)); 
    lcd.print("cm");
    lcd.write((uint8_t)1);
  } else {
    lcd.setCursor(2,2);
    lcd.print("Phi * r");

    lcd.setCursor(9, 2); 
    lcd.write((uint8_t)1);
    lcd.print(":");
    lcd.print(penampunglingkaran ,2); 
    lcd.print("cm");
    lcd.write((uint8_t)1); 
  }
} else {
  float penampunglingkaran = static_cast<float>((valueR * valueR) * 3.14);
  if (penampunglingkaran == (int) penampunglingkaran) {
    lcd.setCursor(2,2);
    lcd.print("Phi * r");

    lcd.setCursor(9, 2); 
    lcd.write((uint8_t)1);
    lcd.print(":");
    lcd.print(((int)penampunglingkaran < 10? "0" : "") + String ((int)penampunglingkaran));
    lcd.print("cm");
    lcd.write((uint8_t)1);    
  } else {
    lcd.setCursor(2,2);
    lcd.print("Phi * r");

    lcd.setCursor(9, 2); 
    lcd.write((uint8_t)1);
    lcd.print(":");
    lcd.print(penampunglingkaran ,2);
    lcd.print("cm");
    lcd.write((uint8_t)1);  
  }
}

goto luaslingkaran;
goto Hasilluaslingkaran;

kelilinglingkaran:

if (digitalRead(TUP) == Tekan && valueR < maxlingkaran ){
  valueR++;
  delay(lama);
} else if (digitalRead(TDOWN) == Tekan && valueR > minlingkaran){
  valueR--;
  delay(lama);
} else if (digitalRead(TOK) == Tekan) {
  delay(waktu);
  while (digitalRead(TOK) == Tekan){}
  lcd.clear();
  goto Hasilkelilinglingkaran;
} else if (digitalRead(TK) == Tekan){
  delay(waktu);
  while (digitalRead(TK) == Tekan){}
  lcd.clear();
  valueR = 0;
  goto setpilihlingkaran2;
}

lcd.setCursor(1,1);
lcd.print("r : ");
lcd.print((valueR < 10? "0" : "") + String (valueR)); 

lcd.setCursor(1,2);
lcd.print("2 * Phi * r:");

goto kelilinglingkaran;

Hasilkelilinglingkaran:

if (valueR % 7 == 0) {
  float penampunglingkaran = static_cast<float>((valueR * 2 ) * 22 ) / 7;
  if (penampunglingkaran == (int) penampunglingkaran) {
    lcd.setCursor(1,2);
    lcd.print("2 * Phi * r:");

    lcd.setCursor(13, 2); 
    lcd.print(((int)penampunglingkaran < 10? "0" : "") + String ((int)penampunglingkaran));
    lcd.print("cm"); 
  } else {
    lcd.setCursor(1,2);
    lcd.print("2 * Phi * r:");

    lcd.setCursor(13, 2); 
    lcd.print(penampunglingkaran ,1);
    lcd.print("cm");  
  }
} else {
  float penampunglingkaran = static_cast<float>((valueR * 2) * 3.14);
  if (penampunglingkaran == (int) penampunglingkaran) {
    lcd.setCursor(1,2);
    lcd.print("2 * Phi * r:");

    lcd.setCursor(13, 2);
    lcd.print(((int)penampunglingkaran < 10? "0" : "") + String ((int)penampunglingkaran));
    lcd.print("cm");
  } else {
    lcd.setCursor(1,2);
    lcd.print("2 * Phi * r:");

    lcd.setCursor(13, 2); 
    lcd.print(penampunglingkaran ,1); 
    lcd.print("cm"); 
  }
}

goto kelilinglingkaran;
goto Hasilkelilinglingkaran;

setpilihsegitiga:

 if (digitalRead(TUP) == Tekan){
  delay(waktu);
  while(digitalRead(TUP) == Tekan){}
  lcd.clear();
  goto setpilihsegitiga2;
} else if(digitalRead(TDOWN) == Tekan){
  delay(waktu);
  while(digitalRead(TDOWN) == Tekan){}
  lcd.clear();
  goto setpilihsegitiga2;
} else if (digitalRead(TOK) == Tekan){
  delay(waktu);
  while(digitalRead(TOK) == Tekan){}
  lcd.clear();
 goto  kelilingsegitiga;
} else if (digitalRead(TK) == Tekan){
  delay(waktu);
  while (digitalRead(TK) == Tekan){}
  lcd.clear();
 goto setsegitiga;
}

lcd.setCursor(0,0);
lcd.print(">LUAS");
lcd.setCursor(0,1);
lcd.print(" KELILING");
goto setpilihsegitiga;

setpilihsegitiga2:

 if (digitalRead(TUP) == Tekan){
  delay(waktu);
  while(digitalRead(TUP) == Tekan){}
  lcd.clear();
  goto setpilihsegitiga;
} else if(digitalRead(TDOWN) == Tekan){
  delay(waktu);
  while(digitalRead(TDOWN) == Tekan){}
  lcd.clear();
  goto setpilihsegitiga;
} else if (digitalRead(TOK) == Tekan){
  delay(waktu);
  while(digitalRead(TOK) == Tekan){}
  lcd.clear();
  goto luassegitiga;
} else if (digitalRead(TK) == Tekan){
  delay(waktu);
  while (digitalRead(TK) == Tekan){}
  lcd.clear();
 goto setsegitiga;
}
lcd.setCursor(0,0);
lcd.print(" LUAS");
lcd.setCursor(0,1);
lcd.print(">KELILING");

goto setpilihsegitiga2;

luassegitiga:
luasA:
if (digitalRead(TUP) == Tekan && valuesegitiga1 < maxsegitiga ){
  valuesegitiga1++;
  delay(lama);
} else if (digitalRead(TDOWN) == Tekan && valuesegitiga1 > minsegitiga){
  valuesegitiga1--;
  delay(lama);
} else if (digitalRead(TOK) == Tekan) {
  delay(waktu);
  while (digitalRead(TOK) == Tekan){}
  goto Hasilluassegitiga;
} else if (digitalRead(TK) == Tekan){
  delay(waktu);
  while (digitalRead(TK) == Tekan){}
  lcd.clear();
  valuesegitiga1 = 0;
  goto setpilihsegitiga2;
}
lcd.setCursor(1,1);
lcd.print("S : ");
lcd.print((valuesegitiga1 < 10? "0" : "") + String (valuesegitiga1)); 

lcd.setCursor(1,2);
lcd.print("4 * S :");

goto luasA;
goto luassegitiga;

Hasilluassegitiga:

penampungsegitiga = (4 * valuesegitiga1);

lcd.setCursor(1,2);
lcd.print("4 * S :");
lcd.print((penampungsegitiga < 10? "0" : "") + String (penampungsegitiga));
lcd.print("cm"); 
goto luassegitiga;
goto Hasilluassegitiga;

kelilingsegitiga:
kelilingA:
if (digitalRead(TUP) == Tekan && valuesegitiga1 < maxsegitiga ){
  valuesegitiga1++;
  delay(lama);
} else if (digitalRead(TDOWN) == Tekan && valuesegitiga1 > minsegitiga){
  valuesegitiga1--;
  delay(lama);
} else if (digitalRead(TOK) == Tekan) {
  delay(waktu);
  while (digitalRead(TOK) == Tekan){}
  goto kelilingB;
} else if (digitalRead(TK) == Tekan){
  delay(waktu);
  while (digitalRead(TK) == Tekan){}
  lcd.clear();
  valuesegitiga1 = 0;
  valuesegitiga2 = 0;
  goto setpilihsegitiga;
}
lcd.setCursor(1,1);
lcd.print("D1 : ");
lcd.print((valuesegitiga1 < 10? "0" : "") + String (valuesegitiga1)); 

lcd.setCursor(1,2);
lcd.print("D2 : ");
lcd.print((valuesegitiga2 < 10? "0" : "") + String (valuesegitiga2));

lcd.setCursor(1,3);
lcd.print("1/2*D1*D2 :");
goto kelilingA;

kelilingB:

if (digitalRead(TUP) == Tekan && valuesegitiga2 < maxsegitiga ){
  valuesegitiga2++;
  delay(lama);
} else if (digitalRead(TDOWN) == Tekan && valuesegitiga2 > minsegitiga){
  valuesegitiga2--;
  delay(lama);
} else if (digitalRead(TOK) == Tekan) {
  delay(waktu);
  while (digitalRead(TOK) == Tekan){}
  goto Hasilkelilingsegitiga;
} else if (digitalRead(TK) == Tekan){
  delay(waktu);
  while (digitalRead(TK) == Tekan){}
  lcd.clear();
  valuesegitiga1 = 0;
  valuesegitiga2 = 0;
  goto setpilihsegitiga;
}
lcd.setCursor(1,1);
lcd.print("D1 : ");
lcd.print((valuesegitiga1 < 10? "0" : "") + String (valuesegitiga1)); 

lcd.setCursor(1,2);
lcd.print("D2 : ");
lcd.print((valuesegitiga2 < 10? "0" : "") + String (valuesegitiga2));

lcd.setCursor(1,3);
lcd.print("1/2*D1*D2 :");
goto kelilingB;
goto kelilingsegitiga;

Hasilkelilingsegitiga:

lcd.createChar(1,dua);
penampungsegitiga = ((valuesegitiga1 * valuesegitiga2) / 2);

lcd.setCursor(1,3);
lcd.print("1/2*D1*D2 :");
lcd.print((penampungsegitiga < 10? "0" : "") + String (penampungsegitiga));
lcd.print("cm");
lcd.write((uint8_t)1);
goto kelilingsegitiga;
goto Hasilkelilingsegitiga;

// TRIGONOMETRI
TAMPILTRI:  

if (digitalRead(TOK) == Tekan){
  delay(waktu);
  while(digitalRead(TOK) == Tekan){}
  lcd.clear();
  goto menusin1;
} else if (digitalRead(TK) == Tekan){
  delay(waktu);
  while (digitalRead(TK) == Tekan){}
  lcd.clear();
 goto setmenu2;
}

goto TAMPILTRI;

menusin1:

tampil();
if (digitalRead(TUP) == Tekan){
  delay(waktu);
  while(digitalRead(TUP) == Tekan){}
  goto menutan1;
} else if(digitalRead(TDOWN) == Tekan){
  delay(waktu);
  while(digitalRead(TDOWN) == Tekan){}
  goto menucos1;
} else if (digitalRead(TOK) == Tekan){
  delay(waktu);
  while(digitalRead(TOK) == Tekan){}
  goto hasilsinus1;
} else if (digitalRead(TK) == Tekan){
  delay(waktu);
  while (digitalRead(TK) == Tekan){}
  lcd.clear();
 goto setmenu2;
}
lcd.setCursor(8,1);
lcd.print("SIN A = ");

goto menusin1;

hasilsinus1:

 lcd.setCursor(8,1);
 lcd.print("SIN A = ");

  lcd.createChar(6,a);
  lcd.createChar(7,b);
  lcd.createChar(8,c);

  lcd.setCursor(16, 1); 
  lcd.write((uint8_t)6);
  lcd.setCursor(17, 1); 
  lcd.write((uint8_t)7);

  lcd.setCursor(18,1);
  lcd.print("/");

  lcd.setCursor(16, 2); 
  lcd.write((uint8_t)8);
  lcd.setCursor(17, 2); 
  lcd.write((uint8_t)6);


goto TAMPILTRI;
goto hasilsinus1;

menucos1:

tampil();
  
if (digitalRead(TUP) == Tekan){
  delay(waktu);
  while(digitalRead(TUP) == Tekan){}
  goto menusin1;
} else if(digitalRead(TDOWN) == Tekan){
  delay(waktu);
  while(digitalRead(TDOWN) == Tekan){}
  goto menutan1;
} else if (digitalRead(TOK) == Tekan){
  delay(waktu);
  while(digitalRead(TOK) == Tekan){}
 goto hasilcos1;
} else if (digitalRead(TK) == Tekan){
  delay(waktu);
  while (digitalRead(TK) == Tekan){}
  lcd.clear();
 goto setmenu2;
}
lcd.setCursor(8,1);
lcd.print("COS A = ");

goto menucos1;

hasilcos1:

 lcd.setCursor(8,1);
 lcd.print("COS A = ");

  lcd.createChar(6,a);
  lcd.createChar(7,b);
  lcd.createChar(8,c);

  lcd.setCursor(16, 1); 
  lcd.write((uint8_t)8);
  lcd.setCursor(17, 1); 
  lcd.write((uint8_t)7);

  lcd.setCursor(18,1);
  lcd.print("/");

  lcd.setCursor(16, 2); 
  lcd.write((uint8_t)8);
  lcd.setCursor(17, 2); 
  lcd.write((uint8_t)6);


goto TAMPILTRI;
goto hasilcos1;

menutan1:

tampil();
if (digitalRead(TUP) == Tekan){
  delay(waktu);
  while(digitalRead(TUP) == Tekan){}
  goto menucos1;
} else if(digitalRead(TDOWN) == Tekan){
  delay(waktu);
  while(digitalRead(TDOWN) == Tekan){}
  goto menusin1;
} else if (digitalRead(TOK) == Tekan){
  delay(waktu);
  while(digitalRead(TOK) == Tekan){}
 goto hasiltan1;
} else if (digitalRead(TK) == Tekan){
  delay(waktu);
  while (digitalRead(TK) == Tekan){}
  lcd.clear();
 goto setmenu2;
}
lcd.setCursor(8,1);
lcd.print("TAN A = ");

goto menutan1;

hasiltan1:

 lcd.setCursor(8,1);
 lcd.print("TAN A = ");

  lcd.createChar(6,a);
  lcd.createChar(7,b);
  lcd.createChar(8,c);

  lcd.setCursor(16, 1); 
  lcd.write((uint8_t)6);
  lcd.setCursor(17, 1); 
  lcd.write((uint8_t)7);

  lcd.setCursor(18,1);
  lcd.print("/");

  lcd.setCursor(16, 2); 
  lcd.write((uint8_t)8);
  lcd.setCursor(17, 2); 
  lcd.write((uint8_t)7);

goto TAMPILTRI;
goto hasiltan1;

// DI BAWAH CODE PHYTAGORAS
  nilaiA:

 if (digitalRead(TUP) == Tekan){
  delay(waktu);
  while(digitalRead(TUP) == Tekan){}
  lcd.clear();
  goto nilaiC;
} else if(digitalRead(TDOWN) == Tekan){
  delay(waktu);
  while(digitalRead(TDOWN) == Tekan){}
  lcd.clear();
  goto nilaiB;
} else if (digitalRead(TOK) == Tekan){
  delay(waktu);
  while(digitalRead(TOK) == Tekan){}
  lcd.clear();
 goto TAMPILA;
} else if (digitalRead(TK) == Tekan){
  delay(waktu);
  while (digitalRead(TK) == Tekan){}
  lcd.clear();
 goto setmenu3;
}

   lcd.setCursor(0,0);
   lcd.print(">MENCARI NILAI A");
   lcd.setCursor(0,1);
   lcd.print(" MENCARI NILAI B");
   lcd.setCursor(0,2);
   lcd.print(" MENCARI NILAI C");

  goto nilaiA;

  nilaiB:

 if (digitalRead(TUP) == Tekan){
  delay(waktu);
  while(digitalRead(TUP) == Tekan){}
  lcd.clear();
  goto nilaiA;
} else if(digitalRead(TDOWN) == Tekan){
  delay(waktu);
  while(digitalRead(TDOWN) == Tekan){}
  lcd.clear();
  goto nilaiC;
} else if (digitalRead(TOK) == Tekan){
  delay(waktu);
  while(digitalRead(TOK) == Tekan){}
  lcd.clear();
 goto TAMPILB;
} else if (digitalRead(TK) == Tekan){
  delay(waktu);
  while (digitalRead(TK) == Tekan){}
  lcd.clear();
 goto setmenu3;
}

   lcd.setCursor(0,0);
   lcd.print(" MENCARI NILAI A");
   lcd.setCursor(0,1);
   lcd.print(">MENCARI NILAI B");
   lcd.setCursor(0,2);
   lcd.print(" MENCARI NILAI C");

  goto nilaiB;

  nilaiC:

 if (digitalRead(TUP) == Tekan){
  delay(waktu);
  while(digitalRead(TUP) == Tekan){}
  lcd.clear();
  goto nilaiB;
} else if(digitalRead(TDOWN) == Tekan){
  delay(waktu);
  while(digitalRead(TDOWN) == Tekan){}
  lcd.clear();
  goto nilaiA;
} else if (digitalRead(TOK) == Tekan){
  delay(waktu);
  while(digitalRead(TOK) == Tekan){}
  lcd.clear();
 goto TAMPILC;
} else if (digitalRead(TK) == Tekan){
  delay(waktu);
  while (digitalRead(TK) == Tekan){}
  lcd.clear();
 goto setmenu3;
}

   lcd.setCursor(0,0);
   lcd.print(" MENCARI NILAI A");
   lcd.setCursor(0,1);
   lcd.print(" MENCARI NILAI B");
   lcd.setCursor(0,2);
   lcd.print(">MENCARI NILAI C");

  goto nilaiC;


TAMPILA:
  lcd.createChar(1,datarbawah);
  lcd.createChar(2,siku2);
  lcd.createChar(3,menurun1);
  lcd.createChar(4,menurun2);
  lcd.createChar(5,menurun3);
  lcd.createChar(6,dua);
  lcd.createChar(7,b);
  lcd.createChar(8,c);


  lcd.setCursor(2, 1); 
  lcd.write((uint8_t)1);
  lcd.setCursor(2,2);
  lcd.write((uint8_t)2);
  lcd.setCursor(3,1);
  lcd.write((uint8_t)3);
  lcd.setCursor(3,2);
  lcd.write((uint8_t)4);
  lcd.setCursor(4,2);
  lcd.write((uint8_t)5);

  lcd.setCursor(1,1);
  lcd.print("?");
  lcd.setCursor(3,3);
  lcd.write((uint8_t)7);
  lcd.setCursor(4,1);
  lcd.write((uint8_t)8);

goto caria;
goto TAMPILA;

  caria:

 lcd.setCursor(7,3);
 lcd.print("A");
 lcd.setCursor(8,3);
 lcd.write((uint8_t)6);
 lcd.setCursor(9,3);
 lcd.print("=");
 lcd.setCursor(10,3);
 lcd.print("B");
 lcd.setCursor(11,3);
 lcd.write((uint8_t)6);
 lcd.setCursor(12,3);
 lcd.print("-");
 lcd.setCursor(13,3);
 lcd.print("C");
 lcd.setCursor(14,3);
 lcd.write((uint8_t)6);
 lcd.setCursor(15,3);
 lcd.print("= ");

if (digitalRead(TUP) == Tekan && valuec < maxphytagoras ){
  valuec++;
  delay(lama);
 } else if (digitalRead(TDOWN) == Tekan && valuec > minphytagoras){
  valuec--;
  delay(lama);
} else if (digitalRead(TOK) == Tekan) {
  delay(waktu);
  while (digitalRead(TOK) == Tekan){}
  goto carib;
} else if (digitalRead(TK) == Tekan){
  delay(waktu);
  while (digitalRead(TK) == Tekan){}
  lcd.clear();
  penampungA = 0;
  valuec = 0;
  valueb = 0;
  goto nilaiA;
} 

  lcd.setCursor(7,1);
  lcd.print("NILAI C : ");
  lcd.print((valuec < 10? "0" : "") + String (valuec)); 

  lcd.setCursor(7,2);
  lcd.print("NILAI B : ");
  lcd.print((valueb < 10? "0" : "") + String (valueb)); 

  goto caria;

 lcd.setCursor(7,3);
 lcd.print("A");
 lcd.setCursor(8,3);
 lcd.write((uint8_t)6);
 lcd.setCursor(9,3);
 lcd.print("=");
 lcd.setCursor(10,3);
 lcd.print("B");
 lcd.setCursor(11,3);
 lcd.write((uint8_t)6);
 lcd.setCursor(12,3);
 lcd.print("-");
 lcd.setCursor(13,3);
 lcd.print("C");
 lcd.setCursor(14,3);
 lcd.write((uint8_t)6);
 lcd.setCursor(15,3);
 lcd.print("= ");

  carib:
  if (digitalRead(TUP) == Tekan && valueb < maxphytagoras ){
    valueb++;
    delay(lama);
  } else if (digitalRead(TDOWN) == Tekan && valueb > minphytagoras){
    valueb--;
    delay(lama);
  } else if (digitalRead(TOK) == Tekan) {
    delay(waktu);
    while (digitalRead(TOK) == Tekan){}
    lcd.clear();
    goto Hasilphytagorasa;
  } else if (digitalRead(TK) == Tekan){
    delay(waktu);
    while (digitalRead(TK) == Tekan){}
    lcd.clear();
    penampungA = 0;
    valuec = 0;
    valueb = 0;
    goto nilaiA;
  } 
  lcd.setCursor(7,1);
  lcd.print("NILAI C : ");
  lcd.print((valuec < 10? "0" : "") + String (valuec)); 

  lcd.setCursor(7,2);
  lcd.print("NILAI B : ");
  lcd.print((valueb < 10? "0" : "") + String (valueb)); 

  goto carib;

  Hasilphytagorasa:

  penampungphytagoras = (valuec * valuec) - (valueb * valueb);
  penampungA = sqrt(penampungphytagoras);

 lcd.setCursor(7,3);
 lcd.print("A");
 lcd.setCursor(8,3);
 lcd.write((uint8_t)6);
 lcd.setCursor(9,3);
 lcd.print("=");
 lcd.setCursor(10,3);
 lcd.print("B");
 lcd.setCursor(11,3);
 lcd.write((uint8_t)6);
 lcd.setCursor(12,3);
 lcd.print("-");
 lcd.setCursor(13,3);
 lcd.print("C");
 lcd.setCursor(14,3);
 lcd.write((uint8_t)6);
 lcd.setCursor(15,3);
 lcd.print("= ");

  lcd.print((penampungA < 10? "0" : "") + String (penampungA)); 

  goto TAMPILA;
  goto Hasilphytagorasa;

  //===============================

TAMPILB:
  lcd.createChar(1,datarbawah);
  lcd.createChar(2,siku2);
  lcd.createChar(3,menurun1);
  lcd.createChar(4,menurun2);
  lcd.createChar(5,menurun3);
  lcd.createChar(6,dua);
  lcd.createChar(7,a);
  lcd.createChar(8,c);


  lcd.setCursor(2, 1); 
  lcd.write((uint8_t)1);
  lcd.setCursor(2,2);
  lcd.write((uint8_t)2);
  lcd.setCursor(3,1);
  lcd.write((uint8_t)3);
  lcd.setCursor(3,2);
  lcd.write((uint8_t)4);
  lcd.setCursor(4,2);
  lcd.write((uint8_t)5);

  lcd.setCursor(1,1);
  lcd.write((uint8_t)7);
  lcd.setCursor(3,3);
  lcd.print("?");
  lcd.setCursor(4,1);
  lcd.write((uint8_t)8);

goto carib1;
goto TAMPILB;

  carib1:

 lcd.setCursor(7,3);
 lcd.print("B");
 lcd.setCursor(8,3);
 lcd.write((uint8_t)6);
 lcd.setCursor(9,3);
 lcd.print("=");
 lcd.setCursor(10,3);
 lcd.print("C");
 lcd.setCursor(11,3);
 lcd.write((uint8_t)6);
 lcd.setCursor(12,3);
 lcd.print("-");
 lcd.setCursor(13,3);
 lcd.print("A");
 lcd.setCursor(14,3);
 lcd.write((uint8_t)6);
 lcd.setCursor(15,3);
 lcd.print("= ");

if (digitalRead(TUP) == Tekan && valuec < maxphytagoras ){
  valuec++;
  delay(lama);
 } else if (digitalRead(TDOWN) == Tekan && valuec > minphytagoras){
  valuec--;
  delay(lama);
} else if (digitalRead(TOK) == Tekan) {
  delay(waktu);
  while (digitalRead(TOK) == Tekan){}
  goto caria1;
} else if (digitalRead(TK) == Tekan){
  delay(waktu);
  while (digitalRead(TK) == Tekan){}
  lcd.clear();
  penampungB = 0;
  valuec = 0;
  valuea = 0;
  goto nilaiB;
} 

  lcd.setCursor(7,1);
  lcd.print("NILAI C : ");
  lcd.print((valuec < 10? "0" : "") + String (valuec)); 

  lcd.setCursor(7,2);
  lcd.print("NILAI A : ");
  lcd.print((valuea < 10? "0" : "") + String (valuea)); 

  goto carib1;

 lcd.setCursor(7,3);
 lcd.print("B");
 lcd.setCursor(8,3);
 lcd.write((uint8_t)6);
 lcd.setCursor(9,3);
 lcd.print("=");
 lcd.setCursor(10,3);
 lcd.print("C");
 lcd.setCursor(11,3);
 lcd.write((uint8_t)6);
 lcd.setCursor(12,3);
 lcd.print("-");
 lcd.setCursor(13,3);
 lcd.print("A");
 lcd.setCursor(14,3);
 lcd.write((uint8_t)6);
 lcd.setCursor(15,3);
 lcd.print("= ");

  caria1:
  if (digitalRead(TUP) == Tekan && valuea < maxphytagoras ){
    valuea++;
    delay(lama);
  } else if (digitalRead(TDOWN) == Tekan && valuea > minphytagoras){
    valuea--;
    delay(lama);
  } else if (digitalRead(TOK) == Tekan) {
    delay(waktu);
    while (digitalRead(TOK) == Tekan){}
    lcd.clear();
    goto Hasilphytagorasb;
  } else if (digitalRead(TK) == Tekan){
    delay(waktu);
    while (digitalRead(TK) == Tekan){}
    lcd.clear();
    penampungB = 0;
    valuec = 0;
    valuea = 0;
    goto nilaiB;
  } 
  lcd.setCursor(7,1);
  lcd.print("NILAI C : ");
  lcd.print((valuec < 10? "0" : "") + String (valuec)); 

  lcd.setCursor(7,2);
  lcd.print("NILAI A : ");
  lcd.print((valuea < 10? "0" : "") + String (valuea)); 

  goto caria1;

  Hasilphytagorasb:

  penampungphytagoras = (valuec * valuec) - (valuea * valuea);
  penampungB = sqrt(penampungphytagoras);

 lcd.setCursor(7,3);
 lcd.print("B");
 lcd.setCursor(8,3);
 lcd.write((uint8_t)6);
 lcd.setCursor(9,3);
 lcd.print("=");
 lcd.setCursor(10,3);
 lcd.print("C");
 lcd.setCursor(11,3);
 lcd.write((uint8_t)6);
 lcd.setCursor(12,3);
 lcd.print("-");
 lcd.setCursor(13,3);
 lcd.print("A");
 lcd.setCursor(14,3);
 lcd.write((uint8_t)6);
 lcd.setCursor(15,3);
 lcd.print("= ");

  lcd.print((penampungB < 10? "0" : "") + String (penampungB)); 

  goto TAMPILB;
  goto Hasilphytagorasb;

//==================================================
// nilai c
TAMPILC:
  lcd.createChar(1,datarbawah);
  lcd.createChar(2,siku2);
  lcd.createChar(3,menurun1);
  lcd.createChar(4,menurun2);
  lcd.createChar(5,menurun3);
  lcd.createChar(6,dua);
  lcd.createChar(7,a);
  lcd.createChar(8,b);


  lcd.setCursor(2, 1); 
  lcd.write((uint8_t)1);
  lcd.setCursor(2,2);
  lcd.write((uint8_t)2);
  lcd.setCursor(3,1);
  lcd.write((uint8_t)3);
  lcd.setCursor(3,2);
  lcd.write((uint8_t)4);
  lcd.setCursor(4,2);
  lcd.write((uint8_t)5);

  lcd.setCursor(1,1);
  lcd.write((uint8_t)7);
  lcd.setCursor(3,3);
  lcd.write((uint8_t)8);
  lcd.setCursor(4,1);
  lcd.print("?");

goto caria2;
goto TAMPILC;

  caria2:

 lcd.setCursor(7,3);
 lcd.print("C");
 lcd.setCursor(8,3);
 lcd.write((uint8_t)6);
 lcd.setCursor(9,3);
 lcd.print("=");
 lcd.setCursor(10,3);
 lcd.print("A");
 lcd.setCursor(11,3);
 lcd.write((uint8_t)6);
 lcd.setCursor(12,3);
 lcd.print("+");
 lcd.setCursor(13,3);
 lcd.print("B");
 lcd.setCursor(14,3);
 lcd.write((uint8_t)6);
 lcd.setCursor(15,3);
 lcd.print("= ");

if (digitalRead(TUP) == Tekan && valuea < maxphytagoras ){
  valuea++;
  delay(lama);
 } else if (digitalRead(TDOWN) == Tekan && valuea > minphytagoras){
  valuea--;
  delay(lama);
} else if (digitalRead(TOK) == Tekan) {
  delay(waktu);
  while (digitalRead(TOK) == Tekan){}
  goto carib2;
} else if (digitalRead(TK) == Tekan){
  delay(waktu);
  while (digitalRead(TK) == Tekan){}
  lcd.clear();
  penampungC = 0;
  valuea = 0;
  valueb = 0;
  goto nilaiC;
} 

  lcd.setCursor(7,1);
  lcd.print("NILAI A : ");
  lcd.print((valuea < 10? "0" : "") + String (valuea)); 

  lcd.setCursor(7,2);
  lcd.print("NILAI B : ");
  lcd.print((valueb < 10? "0" : "") + String (valueb)); 

  goto caria2;

 lcd.setCursor(7,3);
 lcd.print("C");
 lcd.setCursor(8,3);
 lcd.write((uint8_t)6);
 lcd.setCursor(9,3);
 lcd.print("=");
 lcd.setCursor(10,3);
 lcd.print("A");
 lcd.setCursor(11,3);
 lcd.write((uint8_t)6);
 lcd.setCursor(12,3);
 lcd.print("+");
 lcd.setCursor(13,3);
 lcd.print("B");
 lcd.setCursor(14,3);
 lcd.write((uint8_t)6);
 lcd.setCursor(15,3);
 lcd.print("= ");

  carib2:
  if (digitalRead(TUP) == Tekan && valueb < maxphytagoras ){
    valueb++;
    delay(lama);
  } else if (digitalRead(TDOWN) == Tekan && valueb > minphytagoras){
    valueb--;
    delay(lama);
  } else if (digitalRead(TOK) == Tekan) {
    delay(waktu);
    while (digitalRead(TOK) == Tekan){}
    lcd.clear();
    goto Hasilphytagorasc;
  } else if (digitalRead(TK) == Tekan){
    delay(waktu);
    while (digitalRead(TK) == Tekan){}
    lcd.clear();
    penampungC = 0;
    valuea = 0;
    valueb = 0;
    goto nilaiC;
  } 
  lcd.setCursor(7,1);
  lcd.print("NILAI A : ");
  lcd.print((valuea < 10? "0" : "") + String (valuea)); 

  lcd.setCursor(7,2);
  lcd.print("NILAI B : ");
  lcd.print((valueb < 10? "0" : "") + String (valueb)); 

  goto carib2;

  Hasilphytagorasc:

  penampungphytagoras = (valuea * valuea) + (valueb * valueb);
  penampungC = sqrt(penampungphytagoras);

 lcd.setCursor(7,3);
 lcd.print("C");
 lcd.setCursor(8,3);
 lcd.write((uint8_t)6);
 lcd.setCursor(9,3);
 lcd.print("=");
 lcd.setCursor(10,3);
 lcd.print("A");
 lcd.setCursor(11,3);
 lcd.write((uint8_t)6);
 lcd.setCursor(12,3);
 lcd.print("+");
 lcd.setCursor(13,3);
 lcd.print("C");
 lcd.setCursor(14,3);
 lcd.write((uint8_t)6);
 lcd.setCursor(15,3);
 lcd.print("= ");

  lcd.print((penampungC < 10? "0" : "") + String (penampungC)); 

  goto TAMPILC;
  goto Hasilphytagorasc;
}

void tampil (){

  lcd.createChar(1,datarbawah);
  lcd.createChar(2,siku2);
  lcd.createChar(3,menurun1);
  lcd.createChar(4,menurun2);
  lcd.createChar(5,menurun3);
  lcd.createChar(6,a);
  lcd.createChar(7,b);
  lcd.createChar(8,c);

  lcd.setCursor(1, 0); 
  lcd.write((uint8_t)6);
  lcd.setCursor(1, 3); 
  lcd.write((uint8_t)7);
  lcd.setCursor(5, 3); 
  lcd.write((uint8_t)8);
  lcd.setCursor(2, 1); 
  lcd.write((uint8_t)1);
  lcd.setCursor(2,2);
  lcd.write((uint8_t)2);
  lcd.setCursor(3,1);
  lcd.write((uint8_t)3);
  lcd.setCursor(3,2);
  lcd.write((uint8_t)4);
  lcd.setCursor(4,2);
  lcd.write((uint8_t)5);
  
}