//or click buttons with mouse after notes are shown on screen
#include "pitches.h"
#define SPEAKER_PIN 8
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
const uint8_t buttonPins[] = { 12, 11, 10, 9, 7, 6, 5, 4 };
const int buttonTones[] = {
NOTE_FS2, NOTE_D4, NOTE_E4, NOTE_F4,
NOTE_G4, NOTE_A4, NOTE_B4, NOTE_C5
};
const int numTones = sizeof(buttonPins) / sizeof(buttonPins[0]);
void setup() {
lcd.begin(20,4);
lcd.setCursor(4,1);
lcd.print("Green Button(1)");
lcd.setCursor(4,2);
lcd.print("NOTE_FS2");
delay(1000);
lcd.begin(20,4);
lcd.setCursor(4,1);
lcd.print("White Button(2)");
lcd.setCursor(4,2);
lcd.print("NOTE_D4 ");
delay(1000);
lcd.begin(20,4);
lcd.setCursor(4,1);
lcd.print("Grey Button(3)");
lcd.setCursor(4,2);
lcd.print("NOTE_E4 ");
delay(1000);
lcd.begin(20,4);
lcd.setCursor(4,1);
lcd.print("Blue Button(4)");
lcd.setCursor(4,2);
lcd.print("NOTE_F4 ");
delay(1000);
lcd.begin(20,4);
lcd.setCursor(4,1);
lcd.print("Yellow Button(5)");
lcd.setCursor(4,2);
lcd.print("NOTE_G4 ");
delay(1000);
lcd.begin(20,4);
lcd.setCursor(4,1);
lcd.print("Red Button(6) ");
lcd.setCursor(4,2);
lcd.print("NOTE_A4 ");
delay(1000);
lcd.clear();
char waitForKey('1');
if (getc == '1'){
lcd.begin(20,4);
lcd.setCursor(4,2);
lcd.print("Green Button(1)");
}
for (uint8_t i = 0; i < numTones; i++) {
pinMode(buttonPins[i], INPUT_PULLUP);
}
pinMode(SPEAKER_PIN, OUTPUT);
{
}
}
void loop() {
int pitch = 0;
for (uint8_t i = 0; i < numTones; i++) {
if (digitalRead(buttonPins[i]) == LOW) {
pitch = buttonTones[i];
}
}
if (pitch) {
tone(SPEAKER_PIN, pitch);
} else {
noTone(SPEAKER_PIN);
}
}