Hard to explain but here it is simplified.
char sw1 = "closed";
char displaycp = "sw1";
lcd.print(displaycp); //should point to variable sw1 and get the value of it.
Of couse the LCD prints out sw1, I want the LCD to display "closed". So the variable displaycd need to point to the value of variable sw1.
I have been reading all day trying to find a way to make this work, so far no dice.
char sw1 = "closed";
Stop right there. Do not pass GO. Do not collect £200
Maybe I need to explain more and start over in my thinking. I have the following variables defined:
char sw1[] = "closed";
char sw2[] = "4:3";
char sw3[] = "16:9";
char sw4[] = "1.85";
char sw5[] = "2.35";
char sw6[] = "2.40";
char sw7[] = "open";
I have another variable that gets a value from 1-7 based on which input is high.
int currentp;
Then I need to print out the value of sw1-sw7 based on the value of currentp
Now I know I could do a bunch of "IF" statements comparing the value of currentp to do what I want. I was hoping for something cleaner with less lines of code.
I want to combine sw + value of currentp to get sw1, sw2, ect and display the matching value on the LCD. Maybe it is just simpler to do IF statements to what I need.
mopar_mudder:
char sw1[] = "closed";
char sw2[] = "4:3";
char sw3[] = "16:9";
char sw4[] = "1.85";
char sw5[] = "2.35";
char sw6[] = "2.40";
char sw7[] = "open";
I have another variable that gets a value from 1-7 based on which input is high.
int currentp;
Then I need to print out the value of sw1-sw7 based on the value of currentp
I was hoping for something cleaner with less lines of code.
Try an array:
char* mySwitch[] = {"Closed", "4:3", ... };
Array worked perfect, thank you very much.