#include #include #include #include #include #include LiquidCrystal_I2C lcd(0x27, 16, 2); Sd2Card card; SdVolume volume; SdFile root; // Make another array and make the arrays equaltoean char *mainArray[100]; char *mainArrayTone[100]; int indexSelect = 0; int indexSelectTone = 0; int firstNull = 5; int lastValue = 4; int upButton = 0; int upButtonPrev = 0; int downButton = 0; int downButtonPrev = 0; int playButton = 0; int playButtonPrev = 0; int playButtonPin = 6; int downButtonPin = 5; int upButtonPin = 4; AudioPlaySdWav playSdWav1; //xy=306,67 AudioOutputAnalog dac1; //xy=469,296 AudioConnection patchCord1(playSdWav1, 1, dac1, 0); #define SDCARD_CS_PIN BUILTIN_SDCARD #define SDCARD_MOSI_PIN 11 // not actually used #define SDCARD_SCK_PIN 13 // not actually used void setup() { lcd.init(); Serial.begin(9600); pinMode(downButtonPin,INPUT); pinMode(upButtonPin,INPUT); pinMode(playButtonPin,INPUT); AudioMemory(8); mainArray[0] = {"Homescreen"}; mainArray[1] = {"Levan"}; mainArray[2] = {"Chang-Siu"}; mainArray[3] = {"Clyatt"}; mainArray[4] = {"Green"}; mainArrayTone[0] = {"LEVAN.WAV"}; mainArrayTone[1] = {"LEVAN.WAV"}; mainArrayTone[2] = {"CHANGSIU.WAV"}; mainArrayTone[3] = {"CLYATT.WAV"}; mainArrayTone[4] = {"LEAN.WAV"}; // Open serial communications and wait for port to open: Serial.begin(9600); while (!Serial) { ; // wait for serial port to connect. Needed for Leonardo only } if (!(SD.begin(SDCARD_CS_PIN))) { // stop here, but print a message repetitively while (1) { Serial.println("Unable to access the SD card"); delay(500); } } } void playFile(const char *filename) { Serial.print("Playing file: "); Serial.println(filename); // Start playing the file. This sketch continues to // run while the file plays. playSdWav1.play(filename); // A brief delay for the library read WAV info delay(5); // Simply wait for the file to finish playing. while (playSdWav1.isPlaying()) { // uncomment these lines if you audio shield // has the optional volume pot soldered //float vol = analogRead(15); //vol = vol / 1024; // sgtl5000_1.volume(vol); } } void loop() { upButtonPrev = upButton; upButton = digitalRead(upButtonPin); downButtonPrev = downButton; downButton = digitalRead(downButtonPin); playButtonPrev = playButton; playButton = digitalRead (playButtonPin); if (upButton == HIGH && upButtonPrev == LOW) { delay(100); indexSelect = indexSelect + 1; indexSelectTone = indexSelectTone + 1; lcd.clear(); if (indexSelect == firstNull) { indexSelect = 0; indexSelectTone = 0; }//end max }//end up if statement if (downButton == HIGH && downButtonPrev == LOW) { delay(100); indexSelect = indexSelect - 1; indexSelectTone = indexSelectTone - 1; lcd.clear(); if (indexSelect < 0) { indexSelect = lastValue; indexSelectTone = 4; }//end min }//end down if statement Serial.println(mainArray[indexSelect]); Serial.println(mainArrayTone[indexSelectTone]); if (playButton == HIGH && playButtonPrev == LOW) { playFile(mainArrayTone[indexSelectTone]); delay(500); indexSelect = 0; indexSelectTone = 0; } lcd.setCursor(3, 0); lcd.print(mainArray[indexSelect]); }