i am trying to control what is being displayed on my LCD with multiple push buttons. the first thing that will appear when i select the first button (connected to digital pin 7) is "what genre would you like to play", I will select that button until my preferred genre is displayed on the screen. to select the genre, you will need to push the button that is connected to digital pin 13 and the songs in this genre will display on the screen that can be clicked through using the same pin 13 button. my issue is when I am trying to select the genre and I push the button connected to pin 13 the screen goes blank instead of showing the songs. anyone know what my issue could be?
i have attached the code for the first genre which is "game songs" and the two songs that should show up when I select it are "Mario super bros theme song" and "jeopardy theme song"
i am trying to control what is being displayed on my LCD with multiple push buttons. the first thing that will appear when i select the first button (connected to digital pin 7) is "what genre would you like to play", I will select that button until my preferred genre is displayed on the screen. to select the genre, you will need to push the button that is connected to digital pin 13 and the songs in this genre will display on the screen that can be clicked through using the same pin 13 button. my issue is when I am trying to select the genre and I push the button connected to pin 13 the screen goes blank instead of showing the songs. anyone know what my issue could be?
i have attached the code for the first genre which is "game songs" and the two songs that should show up when I select it are "Mario super bros theme song" and "jeopardy theme song"
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int LCDswitchPin = 7; // define main menu/LCD switch name
const int LCDGenreSwitchPin = 13; //define genre switch name
int LCDswitchState = 0; // set menu/LCD switch state to off/low
int LCDGenreSwitchState = 0;
int prevLCDswitchState = 0;
int greenLED = 6;
int LCDswitchCounter = 0;
int LCDGenreSwitchCounter = 0;
void setup() {
Serial.begin(9600);
lcd.begin(16, 2);
pinMode(LCDswitchPin, INPUT);
pinMode(LCDGenreSwitchPin, INPUT);
pinMode(greenLED, OUTPUT);
digitalWrite(greenLED, LOW); // LED stays off while piano keys are on
} // end setup
void loop() {
LCDswitchState = digitalRead(LCDswitchPin);
LCDGenreSwitchState = digitalRead(LCDGenreSwitchPin);
int keyVal = analogRead(A0);
Serial.println(keyVal);
lcd.noDisplay();
digitalWrite(greenLED, LOW); // Turn LED back off every time main loop starts
// ************** START "LCDstart" WHEN MENU BUTTON IS PUSHED ***********
if (LCDswitchState == HIGH) {
digitalWrite(greenLED, HIGH); // Turn LED on to show piano keys are disabled and device is in "menu mode"
lcd.display();
lcd.clear();
LCDstart();
}
void LCDstart() {
int keyVal = analogRead(A0);
LCDswitchState = digitalRead(LCDswitchPin); // check state of menu button
while (LCDswitchState == LOW) { // continue loop while menu button isn't pressed
LCDswitchState = digitalRead(LCDswitchPin); // check state of menu button every time loop starts
//************* START SONG 1 TITLE LOOP ********************
if (LCDswitchState == HIGH) { // if menu button is pressed, then...
LCDswitchCounter++; // set button count to 1
Serial.print("number of button pushes: ");
Serial.println(LCDswitchCounter);
delay(300); // min. time until counts adds 1 more
Genre1();
lcd.clear();
break;
}
//************* ELSE SHOW MENU ****************
else { // if menu button is not pressed, then...
LCDswitchCounter=0; // set menu button count to 0
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("WHAT GENRE WOULD");
lcd.setCursor(0, 1);
lcd.print("YOU LIKE TO PLAY");
delay(50); // return to main
}
} // end while
} // end LCDstart loop
// ************* GENRE 1 LOOP STARTS HERE **************
void Genre1() {
int keyVal = analogRead(A0);
LCDswitchState = digitalRead(LCDswitchPin); // check state of menu button again
LCDGenreSwitchState = digitalRead(LCDGenreSwitchPin);
while (LCDswitchState == LOW) { // continue loop while menu button isn't pressed
LCDswitchState = digitalRead(LCDswitchPin); // check state of menu button again
LCDGenreSwitchState = digitalRead(LCDGenreSwitchPin); //check state of Genre button
//************* GENRE 2 LOOP ********************
if (LCDswitchState == HIGH) { // if menu button is pressed, then...
LCDswitchCounter++; // set button count to 2
Serial.print("number of button pushes: ");
Serial.println(LCDswitchCounter);
delay(300); // min. time until counts adds 1 more
Genre2();
lcd.clear();
break;
}
else { // if menu button is not pressed
if(LCDGenreSwitchState == HIGH) {
LCDGenreSwitchCounter++; // set button count to 1
Serial.print("number of button pushes: ");
Serial.println(LCDGenreSwitchCounter);
digitalWrite(greenLED, HIGH);
Genre1titles();
lcd.clear();
break;
} // end if
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(" GAME");
lcd.setCursor(0, 1);
lcd.print(" THEME SONGS");
delay(50);
}
}
}
void Genre1titles() {
int keyVal = analogRead(A0);
LCDGenreSwitchState = digitalRead(LCDGenreSwitchPin); // check state of genre button again
while (LCDGenreSwitchState == LOW) { // continue loop while menu button isn't pressed
//LCDswitchState = digitalRead(LCDswitchPin); // check state of menu button again
LCDGenreSwitchState = digitalRead(LCDGenreSwitchPin);
//************* START SONG 2 TITLE LOOP ********************
if (LCDGenreSwitchState == HIGH) { // if genre button is pressed, then...
LCDGenreSwitchCounter++; // set button count to 2
Serial.print("number of button pushes: ");
Serial.println(LCDGenreSwitchCounter);
delay(300); // min. time until counts adds 1 more
Song2title();
lcd.clear();
break;
}
else { // if genre button is not pressed
int keyVal = analogRead(A0);
Serial.println(keyVal);
if(keyVal >= 2) {
digitalWrite(greenLED, LOW);
Song1();
break;
} // end if
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("SUPER MARIO BROS");
lcd.setCursor(0, 1);
lcd.print(" THEME SONG");
delay(50);
}
}
}
void Song2title() {
int keyVal = analogRead(A0);
LCDGenreSwitchState = digitalRead(LCDGenreSwitchPin);
//LCDswitchState = digitalRead(LCDswitchPin); // check state of menu button again
while (LCDGenreSwitchState == LOW) { // continue loop while menu button isn't pressed
LCDGenreSwitchState = digitalRead(LCDGenreSwitchPin); // check state of menu button again
//************* START SONG 2 LOOP ********************
if (LCDGenreSwitchState == HIGH) { // if menu button is pressed, then...
LCDGenreSwitchCounter-0; // set button count to 0
Serial.print("number of button pushes: ");
Serial.println(LCDGenreSwitchCounter);
delay(300); // min. time until counts adds 1 more
lcd.clear();
}
else { // if menu button is not pressed
int keyVal = analogRead(A0);
Serial.println(keyVal);
if(keyVal >= 2) {
digitalWrite(greenLED, LOW);
Song2();
break;
} // end if
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(" JEOPARDY");
lcd.setCursor(0, 1);
lcd.print(" THEME SONG");
delay(50);
}
}
}
Cross-posting is against the rules of the forum. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend 15 minutes (or more) writing a detailed answer on this topic, without knowing that someone else already did the same in the other topic.
Repeated cross-posting will result in a suspension from the forum.
In the future, please take some time to pick the forum board that best suits the topic of your question and then only post once to that forum board. This is basic forum etiquette, as explained in the sticky "How to use this forum - please read." post you will find at the top of every forum board. It contains a lot of other useful information. Please read it.