Go Down

Topic: LCD menu options (best route) (Read 8 times) previous topic - next topic

jman31

Hope you guys aren't getting sick of me yet. I really appreciate your time and input. I am learning as I go and wearing my google button out! ::)

Here is how I tried to implement your idea PaulS. I still get no entry into the second switch/case. I changed up some of the variable names to make more sense with the project. I hope that doesn't throw too much confusion into the mix.

If I can get this last issue, then maybe I can leave you guys alone for awhile! :D

Code: [Select]
void loop(){
 buttonState = digitalRead(switchPin);
 buttonState2 = digitalRead(switchPin2);

 if (buttonState == HIGH){
   switch(ledstate){
   case LED1:
     lcd.clear();
     lcd.print("Snare");
     digitalWrite(BLUE_PIN,HIGH); //turn blue led off
     digitalWrite(RED_PIN,HIGH); //turn red led off
     delay(100); //wait 100ms
     ledstate = LED2; //transition to red state    
     break; //end of START case              

   case LED2:
     lcd.clear();
     lcd.print("TOM 1");
     digitalWrite(BLUE_PIN,LOW); //turn blue led off
     digitalWrite(RED_PIN,HIGH); //turn red led on
     delay(200); //wait 200ms
     ledstate = LED3; //transition to blue state
     break; //end of RED case

   case LED3:
     lcd.clear();
     lcd.print("TOM 2");
     digitalWrite(RED_PIN,LOW); //turn red led off
     digitalWrite(BLUE_PIN,HIGH); //turn blue led on
     delay(200); //wait 200ms
     ledstate = LED1; //transition to start state
     break; //end of BLUE case
   }

   {
     if (ledstate == LED2)
       if (buttonState2 == HIGH)
         if (buttonState == LOW){
           switch(colorState){
           case COLOR1:
             lcd.clear();
             lcd.print("Color 1");
             colorState = COLOR2; //transition to red state
             break; //end of START case
           case COLOR2:
             lcd.clear();
             lcd.print("Color 2");
             colorState = COLOR3; //transition to blue state
             break; //end of RED case
           case COLOR3:
             lcd.clear();
             lcd.print("Color 3");
             colorState = COLOR1; //transition to start state
             break; //end of BLUE case
           }
         }

   }
 }
}

Groove

This:
Code: [Select]
     if (ledstate == LED2)
       if (buttonState2 == HIGH)
         if (buttonState == LOW){


is the same as writing:
Code: [Select]
     if  ( (ledstate == LED2) &&
           (buttonState2 == HIGH) &&
           (buttonState == LOW)) {
Per Arduino ad Astra

jman31

OK, but will that change anything to make it work?

Groove

No, but it may make it easier to read.
Per Arduino ad Astra

jman31


Go Up