Hi everyone, this is my first time posting, and wanted to thank you all so much for all the effort and time spent answering questions. This forum has been a life line many many times for me, and this is the first time I couldn't find the answer to my question already covered in a post. Likely because of a misunderstanding of something on my part, likely correct terminology.
I have 4 switches that I would like to use to control 8 LEDs. The LEDs controlled by each switch I would like be user defined, via an LCD menu. The user would be able to set any number of leds to switch 1, 2, 3, 4. One LED controlled by multiple switches isnt a concern, so there is no need to remove them from the pool or anything like that.
I have come up with a solution that would likely work, but its so inelegant and inefficient that there has to be a better way. Assigning a variable for each switch to each LED. Something like this:
if (switch1 == HIGH){
if (sw1LED1 == true){digital.Write(LED1, HIGH);}
if (sw1LED2 == true){digital.Write(LED2, HIGH);}
etc...
Not only is that just awful, it would require 32 variables.
I second thought was, 8 LEDs, 8 bits in a byte, maybe I could use each bit to indicate if an LED should be on or off and only use 4 bytes. I know I can see a byte with use of BIN, but Im not at all sure how to use a comparative statement for a single bit of a byte, or how even single one out to compare. Actually that encompasses the totality of my understanding of BIN.
If anyone could point me to some reading or suggest a less clumsy way to go about this, it would be fantastic. Thank you very much for all the help.