switch between outputs

I got the first part sorted. Here is the next problem. Firstly I dont want to change what I have got. Yes, it could be done differently but it is fine how it is!!!

when I switch from one case to another the previous case stays active i.e case 1 lights led 1 etc (only six cases drive an output) press any other case and case 1 stays on. I need it to go off. Even the cases without outputs need to switch any outputs off.

hope this is clear.

Last thing, I really need it to be simple. I am NOT a programmer.

Ta

#include <LiquidCrystal.h> 
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); 
float sensorValue = 0; 

void setup() { 

     pinMode(6, INPUT);
     pinMode(7, INPUT);
     pinMode(8, INPUT);
     pinMode(9, INPUT);
     pinMode(53, OUTPUT); 
     pinMode(51, OUTPUT);
     pinMode(49, OUTPUT); 
     pinMode(47, OUTPUT);
     pinMode(45, OUTPUT); 
     pinMode(43, OUTPUT);
 Serial.begin(9600); 

     //lcd.begin(16, 2); 
    // lcd.print("  Hello your on"); 
     //lcd.setCursor(0, 1); 


} 

void loop() { 

 int buttonState6 = digitalRead(6); 
 int buttonState7 = digitalRead(7); 
 int buttonState8 = digitalRead(8); 
 int buttonState9 = digitalRead(9); 
 static int oldbuttonState = -1; 
 
 delay(10);        // delay in between reads for stability 

int buttonState = buttonState6 + buttonState7 * 2 + buttonState8 * 4 + buttonState9 * 8; 
static boolean tuneaerial = false; 
switch (oldbuttonState) 
 { 

   
} 



if (oldbuttonState != buttonState) { 
 Serial.println(buttonState); 
 digitalWrite(10, LOW); 
 switch (buttonState) 
   { 
       case 0: 
        lcd.clear(); 
        lcd.print("Connect Radio       Connect Radio       "); 
        break; 

        case 1: 
        // code to display sequence 1 on lcd 
        lcd.clear(); 
        lcd.print("160 Meters"); 
         digitalWrite(53, HIGH); 

        break; 

        case 2: 
        // code to display sequence 2 on lcd 
        lcd.clear(); 
        lcd.print("80 Meters "); 
         digitalWrite(51, HIGH);
        break; 

       case 3: 
        // code to display sequence 4 on lcd 
        lcd.clear(); 
        lcd.print("40 Meters "); 
         digitalWrite(49, HIGH);
        break; 

        case 4: 
        // code to display sequence 5 on lcd 
        lcd.clear(); 
        lcd.print("30 Meters"); 
         

        break; 

        case 5: 
        // code to display sequence 6 on lcd 
        lcd.clear(); 
        lcd.print("20 Meters "); 
         digitalWrite(47, HIGH);
        break; 

        case 6: 
        // code to display sequence 7 on lcd 
        lcd.clear(); 
        lcd.print("17 Meters "); 

        break; 

        case 7: 
        // code to display sequence 8 on lcd 
        lcd.clear(); 
        lcd.print("15 Meters "); 
         digitalWrite(45, HIGH);
        break; 

        case 8: 
        // code to display sequence 9 on lcd 
        lcd.clear(); 
        lcd.print("12 Meters "); 

        break; 

        case 9: 
        // code to display sequence 9 on lcd 
        lcd.clear(); 
        lcd.print("10 Meters "); 
         digitalWrite(43, HIGH);
        break; 

   } 
   oldbuttonState = buttonState; 
 } 
}

Sorted it. Missed a couple of lines. I now need a section to read temperature and one to read voltage slotting in somewhere to display on line 3 and 4 of a 20x4 lcd

Any one help please with some code?

 static int oldbuttonState = -1; 
 
 delay(10);        // delay in between reads for stability 

int buttonState = buttonState6 + buttonState7 * 2 + buttonState8 * 4 + buttonState9 * 8; 
static boolean tuneaerial = false; 
switch (oldbuttonState) 
 {    
} 
if (oldbuttonState != buttonState) { 
 Serial.println(buttonState); 
 digitalWrite(53, LOW);
 digitalWrite(51, LOW);
 digitalWrite(49, LOW);
 digitalWrite(47, LOW);
 digitalWrite(45, LOW);
 digitalWrite(43, LOW);
  
 switch (buttonState) 
   { 
       case 0: 
        lcd.clear(); 
        lcd.print("Connect Radio       Connect Radio       "); 
        break; 
        
        case 1: 
        // code to display sequence 1 on lcd 
        lcd.clear(); 
        lcd.print("160 Meters"); 
         digitalWrite(53, HIGH); 

        break; 

        case 2: 
        // code to display sequence 2 on lcd 
        lcd.clear(); 
        lcd.print("80 Meters "); 
         digitalWrite(51, HIGH);
        break; 

       case 3: 
        // code to display sequence 4 on lcd 
        lcd.clear(); 
        lcd.print("40 Meters "); 
         digitalWrite(49, HIGH);
        break; 

        case 4: 
        // code to display sequence 5 on lcd 
        lcd.clear(); 
        lcd.print("30 Meters"); 
         
        break; 

        case 5: 
        // code to display sequence 6 on lcd 
        lcd.clear(); 
        lcd.print("20 Meters "); 
         digitalWrite(47, HIGH);
        break; 

        case 6: 
        // code to display sequence 7 on lcd 
        lcd.clear(); 
        lcd.print("17 Meters "); 

        break; 

        case 7: 
        // code to display sequence 8 on lcd 
        lcd.clear(); 
        lcd.print("15 Meters "); 
         digitalWrite(45, HIGH);
        break; 

        case 8: 
        // code to display sequence 9 on lcd 
        lcd.clear(); 
        lcd.print("12 Meters "); 

        break; 

        case 9: 
        // code to display sequence 9 on lcd 
        lcd.clear(); 
        lcd.print("10 Meters "); 
         digitalWrite(43, HIGH);
        break; 

   } 
   oldbuttonState = buttonState; 
 } 
}

Hi davedpg,

We'd like to help, but need some clarification:

It appears in your first listing, you never turn the LEDs off after you turn them on. The 2nd listing looks like you've added some code to do that. Are you still having the same original problem, or do you have a new problem now? What is it doing now? Does the println that displays the button state do what you think it should do?

Are you asking for code to write to the LCD?

Pat.

davedpg:
I got the first part sorted. Here is the next problem.

Is this intended to mean something to us?

If what you are saying in this Thread is a continuation of another Thread it would IMHO be much more helpful to ask the Moderator to merge the two of them so that everyone has easy access to all the info.

...R