mapping multiple LED to switch on from multiple switches

I am using 3 switches to control 3 LED . The combination are many.
Say -
S1 can control L1 and L2
S2 can conrol L1, L2 and L3

How should I proceed. Should there be any relays, or I need to make multiple wiring like Two way or 3 way switches or any other way s I can do this.

Hi Pradeep and welcome,

Your question does not quite make perfect sense. Can you explain the application? What kind of switches? What kind of leds?

Paul

I have 3 LED (l1,l2,l3) can be mapped to 3 switches (s1, s2, s3) and every switch can be mapped to any number of leds.
For example, I want to set l1,l2 to turn on by s1. l2,l3,l1 to s2 and l2,l3 to s3.. Like this whenever needed I want to assign switches to leds

Perhaps you are looking for something like this? (Semi-Pseudocode)

if(digitalRead(s1))
{
    digitalWrite(LED_1, HIGH);
    digitalWrite(LED_2, HIGH);
}
if(digitalRead(s2))
{
    digitalWrite(LED_1, HIGH);
    digitalWrite(LED_2, HIGH);
    digitalWrite(LED_3, HIGH);
}
if(digitalRead(S3))
{
    digitalWrite(LED_2, HIGH);
    digitalWrite(LED_3, HIGH);
}

This does of course assume that your switches send a high signal when pressed, and of course this routine isn't generic - the "mapping" is hardcoded. I, too, am having trouble understanding what you are asking but I hope this helps :slight_smile:

First thing I would do is establish a truth table of 6 columns. The first 3 columns will be switches and the second 3, the LEDs. Then you put a "1" where any switch goes on and a "1" for any led lit. Say leds 2 and 3 must come on when switches 1 and 2 are on, you would get this:

s1  s2  s3  l1  l2  l3
1    1  0    0   1   1

From there you could reduce any redundancies- say if s1 and s2 together light l3, and s1 and s3 also light l3, you could (maybe) reduce that to s1 by itself.

Then probably code it along the lines of what acegard said