How to read the position of 6 switches.

Hello
Fairly new, but have been reading and learning a lot.
I am working on a project, using Uno Rev.3.
What I have is 6 LED's, each activated by 6 "toggle" switches.
I would like to "monitor" the switches, so that when all 6 switches are HIGH (in any order), a solenoid that I attached to pin 2 using a TIP102 will activate.
Is there a good way to accomplish this? Any existing projects that I could look at, etc.?
Thanks in advance for any input.
Mark

You could connect each of your switches to an input of a 74HC165 parallel in/serial out shift register. I takes 3 wires to control the 165. Clock, latch and data. To read the states of the switches you set the latch and use the shiftIn() function to get the data from the 165. You will need a pullup resistor for each switch. 10K would do. An alternative is an I2C expander like the MCP23008.

Thanks for the suggestion. I did see the shift register is a possibility. But to be honest, I am very new....so I was hoping to get around this with coding and not hardware (if that makes sense)? With my very limited experience, I think it could work as I would be using 6 pins for the switches, 6 pins for the LED's and 1 pin for the solenoid circuit? I am sure the shift register is the better way, but hoping to do it with the hardware I am comfortable with so far. But will try to learn what is involved with the shift register as well.
Mark

Using a pin for each switch is certainly possible and maybe easier. Unless you use direct port manipulation, you would read each switch with a digifalRead. You can save the states in seperate boolean variables or, using bitWrite save the six states in one byte.

you can use pins 2-13 and pins A0

you can digitalWrite to your analog pins.

you can use port manipulation (if you need to know at precisely the same moment) or just read the pins this way, for example... untested

int switchPin[6] = {9,10,11,12,13,A0};  // setup you switch pins into an array
boolean allON;
void setup()
{
  Serial.begin(115200);
  for (int i = 0; i < 6; i++)
  {
    pinMode(switchPin[i], INPUT);
  }
}

void loop () 
{
  for (int i = 0; i < 6; i++)
  {
    digitalRead(switchPin[i]);
    if (switchPin[i] == LOW)
    {
      allON = false;
      break;
    }
    allON = true;
  }
  if (allON)
  {
    // do your allON = true stuff
  }
  // your other programming...
}

Yes, I did know about being able to use the analog pins as digital.
What I have is basically this, Pins 3 through 8 set as output (and each connected to an LED and resistor of course).
Then Pins 9 through 14 as inputs ( and connected to the switches and pulldown resistor (not 100% sure about that, but think I can figure that part out)).
Pin2 set as OUTPUT, connected to TIP 102, and on to a 12v solenoid with a separate power supply.
Each LED and switch function (that is the LED lights when the switch is held down). The solenoid works, when I have pin2 go HIGH.
I am just not far enough along to figure out how to get the code down yet :~
Perhaps that is where the boolean variables or bitWrite come in to play??
I will try to look into both.
I appreciate the comments!
Mark

Thanks Lowell...I see boolean again. And array...I will give your code a try and see how I make out.
I will try to learn a bit more as well. I am sure I will be back with problems and questions.
Thanks
Mark

If you wire one side of the switch to ground and the other to your input pin, you can use the internal pullup resistors and won't need any external resistors (see attached). Use pinMode(pin, INPUT_PULLUP); to enable the internal resistor. Note that the input will be low when the switch is pushed.

You can use this sample sketch to check the overall result of the switches.

byte output;

void setup()
{
  Serial.begin(115200);
  for(byte i = 2; i <= 7; i++)
    pinMode(i, INPUT);
}

void loop() 
{
  output = 0x01; // set output to 1 
  
  for(byte i = 2; i <= 7; i++)
    output &= digitalRead(i); // reads pins 2 - 7, and using the AND logic, it multiples 
                              //each result by output(0x01) and if any of the switchs are LOW
                              // output will equal 0

    if(output == 0x01) // if all switches were high, then output is still 0x01
    {
      // solenoid on 
    }
    else // output = 0x00, a switch was LOW
    {
     //off 
    }
}

NOTE: Make sure you have pull down resistors connected to the arduino pins, otherwise you may have incorrect results.