#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd (0x27, 16,2);

#define nada_C 262
#define nada_D 294
#define nada_E 330
#define nada_F 349
#define nada_G 392
#define nada_A 440
#define nada_B 494
#define nada_C2 523
//inisialisasi pin push button yang terhubung ke arduino
const int C = 1;
const int D = 2;
const int E = 3;
const int F = 4;
const int G = 5;
const int A = 6;
const int B = 7;
const int C2 = 8;
//inisialisasi pin piezoelektrik yang terhubung ke arduino
const int speaker = 13;

void setup() {
  Serial.begin(9600);
  Serial.setTimeout(2000);
  lcd.init();
  lcd.backlight();
  // put your setup code here, to run once:

  //inisialisasi push button sebagai input dan kondisi awalnya HIGH
  pinMode(C, INPUT);
  digitalWrite(C, HIGH);
  pinMode(D, INPUT);
  digitalWrite(D, HIGH);
  pinMode(E, INPUT);
  digitalWrite(E, HIGH);
  pinMode(F, INPUT);
  digitalWrite(F, HIGH);
  pinMode(G, INPUT);
  digitalWrite(G, HIGH);
  pinMode(A, INPUT);
  digitalWrite(A, HIGH);
  pinMode(B, INPUT);
  digitalWrite(B, HIGH);
  pinMode(C2, INPUT);
  digitalWrite(C2, HIGH);
 
}
void loop() {
  // put your main code here, to run repeatedly:
 
  //Selama push button ditekan maka piezo elektrik akan berbunyi sesuai nada yang ditentukan
  while(digitalRead(C) == LOW)
  {
    tone(speaker, nada_C);
  }
  while(digitalRead(D) == LOW)
  {
    tone(speaker, nada_D);
  }
  while(digitalRead(E) == LOW)
  {
    tone(speaker, nada_E);
  }
  while(digitalRead(F) == LOW)
  {
    tone(speaker, nada_F);
  }
  while(digitalRead(G) == LOW)
  {
    tone(speaker, nada_G);
  }
  while(digitalRead(A) == LOW)
  {
    tone(speaker, nada_A);
  }
  while(digitalRead(B) == LOW)
  {
    tone(speaker, nada_B);
  }
  while(digitalRead(C2) == LOW)
  {
    tone(speaker, nada_C2);
  }
  lcd.setCursor(7,0);
  lcd.print("NOT");
if (digitalRead(C) == LOW){
  lcd.setCursor(7,1);
  lcd.print("Do ");}
if (digitalRead(D) == LOW){
  lcd.setCursor(7,1);
  lcd.print("Re ");}
if (digitalRead(E) == LOW){
lcd.setCursor(7,1);
lcd.print("Mi ");}
if (digitalRead(F) == LOW){
lcd.setCursor(7,1);
lcd.print("Fa ");}
if (digitalRead(G) == LOW){
lcd.setCursor(7,1);
lcd.print("Sol");}
if (digitalRead(A) == LOW){
lcd.setCursor(7,1);
lcd.print("La ");}
if (digitalRead(B) == LOW){
lcd.setCursor(7,1);
lcd.print("Si ");}
if (digitalRead(C2) == LOW){
lcd.setCursor(7,1);
lcd.print("Do*");}
//piezoelektrik tidak akan berbunyi jika push button dilepas
  noTone(speaker);
}