user11236: I would like to make this code using the Arduino Uno. I am using three on/off switches and based on the truth table would like to turn on one of 8 LEDs. When I use digitalWrite(), I get an error code saying that there are too few arguments. 
Here is the code
int x = A3;    // select the input pin for the switch
int y = A4;
int z = A5;

int ledPin1 = 2;      // select the pin for the LED
int ledPin2 = 3;
int ledPin3 = 4;
int ledPin4 = 7;
int ledPin5 = 8;
int ledPin6 = 9;
int ledPin7 = 12;
int ledPin8 = 13;

void setup(){

  // declare the ledPin as an OUTPUT:
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
  pinMode(ledPin4, OUTPUT);
  pinMode(ledPin5, OUTPUT);
  pinMode(ledPin6, OUTPUT);
  pinMode(ledPin7, OUTPUT);
  pinMode(ledPin8, OUTPUT);

  pinMode(x, INPUT);
  pinMode(y, INPUT);
  pinMode(z, INPUT);
}

void loop() {

  if ( (x = LOW) && (y = LOW) && (z = LOW))              //condition 1
  {
    digitalWrite (ledPin1 = HIGH); 
    digitalWrite (ledPin2 = LOW); 
    digitalWrite (ledPin3 = LOW); 
    digitalWrite (ledPin4 = LOW); 
    digitalWrite (ledPin5 = LOW); 
    digitalWrite (ledPin6 = LOW); 
    digitalWrite (ledPin7 = LOW); 
    digitalWrite (ledPin8 = LOW); 
  }

  if ( (x = LOW) && (y = LOW) && (z = HIGH))             //condition 2
  {
    ledPin1 = LOW; 
    ledPin2 = HIGH; 
    ledPin3 = LOW; 
    ledPin4 = LOW; 
    ledPin5 = LOW; 
    ledPin6 = LOW; 
    ledPin7 = LOW; 
    ledPin8 = LOW; 
  }

  if ( (x = LOW) && (y = HIGH) && (z = LOW))             //condition 3
  {
    ledPin1 = LOW; 
    ledPin2 = LOW; 
    ledPin3 = HIGH; 
    ledPin4 = LOW; 
    ledPin5 = LOW; 
    ledPin6 = LOW; 
    ledPin7 = LOW; 
    ledPin8 = LOW;
  }

  if ( (x = LOW) && (y = HIGH) && (z = HIGH))              //condition 4
  {
    ledPin1 = LOW; 
    ledPin2 = LOW; 
    ledPin3 = LOW; 
    ledPin4 = HIGH; 
    ledPin5 = LOW; 
    ledPin6 = LOW; 
    ledPin7 = LOW; 
    ledPin8 = LOW;
  }

  if ( (x = HIGH) && (y = LOW) && (z = LOW))               //condition 5
  {
    ledPin1 = LOW; 
    ledPin2 = LOW; 
    ledPin3 = LOW; 
    ledPin4 = LOW; 
    ledPin5 = HIGH; 
    ledPin6 = LOW; 
    ledPin7 = LOW; 
    ledPin8 = LOW;
  }

  if ( (x = HIGH) && (y = LOW) && (z = HIGH))               //condition 6
  {
    ledPin1 = LOW; 
    ledPin2 = LOW; 
    ledPin3 = LOW; 
    ledPin4 = LOW; 
    ledPin5 = LOW; 
    ledPin6 = HIGH; 
    ledPin7 = LOW; 
    ledPin8 = LOW;
  }

  if ( (x = HIGH) && (y = HIGH) && (z = LOW))                //condition 7
  {
    ledPin1 = LOW; 
    ledPin2 = LOW; 
    ledPin3 = LOW; 
    ledPin4 = LOW; 
    ledPin5 = LOW; 
    ledPin6 = LOW; 
    ledPin7 = HIGH; 
    ledPin8 = LOW;
  }

  if ( (x = HIGH) && (y = HIGH) && (z = HIGH))                //condition 8
  {
    ledPin1 = LOW; 
    ledPin2 = LOW; 
    ledPin3 = LOW; 
    ledPin4 = LOW; 
    ledPin5 = LOW; 
    ledPin6 = LOW; 
    ledPin7 = LOW; 
    ledPin8 = HIGH;
  }
}



user38174: Since you mentioned you are new to programming, I am posting your own solution modified to work with right things; this code can be optimize to a great extent if you get good at programming; For your benefit, I will post both your approach and a slightly better approach
Your approach:
int x = A3;    // select the input pin for the switch
int y = A4;
int z = A5;

int ledPin1 = 2;      // select the pin for the LED
int ledPin2 = 3;
int ledPin3 = 4;
int ledPin4 = 7;
int ledPin5 = 8;
int ledPin6 = 9;
int ledPin7 = 12;
int ledPin8 = 13;

void setup(){

    // declare the ledPin as an OUTPUT:
    pinMode(ledPin1, OUTPUT);
    pinMode(ledPin2, OUTPUT);
    pinMode(ledPin3, OUTPUT);
    pinMode(ledPin4, OUTPUT);
    pinMode(ledPin5, OUTPUT);
    pinMode(ledPin6, OUTPUT);
    pinMode(ledPin7, OUTPUT);
    pinMode(ledPin8, OUTPUT);

    pinMode(x, INPUT);
    pinMode(y, INPUT);
    pinMode(z, INPUT);
}

void loop() {

    if ( (x = LOW) && (y = LOW) && (z = LOW))              //condition 1
    {
        digitalWrite (ledPin1, HIGH); 
        digitalWrite (ledPin2, LOW); 
        digitalWrite (ledPin3, LOW); 
        digitalWrite (ledPin4, LOW); 
        digitalWrite (ledPin5, LOW); 
        digitalWrite (ledPin6, LOW); 
        digitalWrite (ledPin7, LOW); 
        digitalWrite (ledPin8, LOW); 
    }

    if ( (x = LOW) && (y = LOW) && (z = HIGH))             //condition 2
    {
        digitalWrite(ledPin1, LOW);  
        digitalWrite(ledPin2, HIGH); 
        digitalWrite(ledPin3, LOW);  
        digitalWrite(ledPin4, LOW);  
        digitalWrite(ledPin5, LOW);  
        digitalWrite(ledPin6, LOW);  
        digitalWrite(ledPin7, LOW);  
        digitalWrite(ledPin8, LOW);  
    }

    if ( (x = LOW) && (y = HIGH) && (z = LOW))             //condition 3
    {
        digitalWrite(ledPin1, LOW);  
        digitalWrite(ledPin2, LOW);  
        digitalWrite(ledPin3, HIGH); 
        digitalWrite(ledPin4, LOW);  
        digitalWrite(ledPin5, LOW);  
        digitalWrite(ledPin6, LOW);  
        digitalWrite(ledPin7, LOW);  
        digitalWrite(ledPin8, LOW); 
    }

    if ( (x = LOW) && (y = HIGH) && (z = HIGH))              //condition 4
    {
        digitalWrite(ledPin1, LOW);  
        digitalWrite(ledPin2, LOW);  
        digitalWrite(ledPin3, LOW);  
        digitalWrite(ledPin4, HIGH); 
        digitalWrite(ledPin5, LOW);  
        digitalWrite(ledPin6, LOW);  
        digitalWrite(ledPin7, LOW);  
        digitalWrite(ledPin8, LOW); 
    }

    if ( (x = HIGH) && (y = LOW) && (z = LOW))               //condition 5
    {
        digitalWrite(ledPin1, LOW);  
        digitalWrite(ledPin2, LOW);  
        digitalWrite(ledPin3, LOW);  
        digitalWrite(ledPin4, LOW);  
        digitalWrite(ledPin5, HIGH); 
        digitalWrite(ledPin6, LOW);  
        digitalWrite(ledPin7, LOW);  
        digitalWrite(ledPin8, LOW); 
    }

    if ( (x = HIGH) && (y = LOW) && (z = HIGH))               //condition 6
    {
        digitalWrite(ledPin1, LOW);  
        digitalWrite(ledPin2, LOW);  
        digitalWrite(ledPin3, LOW);  
        digitalWrite(ledPin4, LOW);  
        digitalWrite(ledPin5, LOW);  
        digitalWrite(ledPin6, HIGH); 
        digitalWrite(ledPin7, LOW);  
        digitalWrite(ledPin8, LOW); 
    }

    if ( (x = HIGH) && (y = HIGH) && (z = LOW))                //condition 7
    {
        digitalWrite(ledPin1, LOW);  
        digitalWrite(ledPin2, LOW);  
        digitalWrite(ledPin3, LOW);  
        digitalWrite(ledPin4, LOW);  
        digitalWrite(ledPin5, LOW);  
        digitalWrite(ledPin6, LOW);  
        digitalWrite(ledPin7, HIGH); 
        digitalWrite(ledPin8, LOW); 
    }

    if ( (x = HIGH) && (y = HIGH) && (z = HIGH))                //condition 8
    {
        digitalWrite(ledPin1, LOW);  
        digitalWrite(ledPin2, LOW);  
        digitalWrite(ledPin3, LOW);  
        digitalWrite(ledPin4, LOW);  
        digitalWrite(ledPin5, LOW);  
        digitalWrite(ledPin6, LOW);  
        digitalWrite(ledPin7, LOW);  
        digitalWrite(ledPin8, HIGH);
    }
}


Slightly better approach:(better programmers may be able to write even more optimized code)
int x = A3;    // select the input pin for the switch
int y = A4;
int z = A5;

int ledPin1 = 2;      // select the pin for the LED
int ledPin2 = 3;
int ledPin3 = 4;
int ledPin4 = 7;
int ledPin5 = 8;
int ledPin6 = 9;
int ledPin7 = 12;
int ledPin8 = 13;

void setup(){

  // declare the ledPin as an OUTPUT:
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
  pinMode(ledPin4, OUTPUT);
  pinMode(ledPin5, OUTPUT);
  pinMode(ledPin6, OUTPUT);
  pinMode(ledPin7, OUTPUT);
  pinMode(ledPin8, OUTPUT);

  pinMode(x, INPUT);
  pinMode(y, INPUT);
  pinMode(z, INPUT);
}

void loop() {
  int pinToTurnHigh = 2; // just making sure its a valid pin
  if ( (x = LOW) && (y = LOW) && (z = LOW))              //condition 1
  {
    pinToTurnHigh = ledPin1;
  }

  if ( (x = LOW) && (y = LOW) && (z = HIGH))             //condition 2
  {
    pinToTurnHigh = ledPin2;
  }

  if ( (x = LOW) && (y = HIGH) && (z = LOW))             //condition 3
  {
    pinToTurnHigh = ledPin3;
  }

  if ( (x = LOW) && (y = HIGH) && (z = HIGH))              //condition 4
  {
    pinToTurnHigh = ledPin4;
  }

  if ( (x = HIGH) && (y = LOW) && (z = LOW))               //condition 5
  {
    pinToTurnHigh = ledPin5;
  }

  if ( (x = HIGH) && (y = LOW) && (z = HIGH))               //condition 6
  {
    pinToTurnHigh = ledPin6;
  }

  if ( (x = HIGH) && (y = HIGH) && (z = LOW))                //condition 7
  {
    pinToTurnHigh = ledPin7;
  }

  if ( (x = HIGH) && (y = HIGH) && (z = HIGH))                //condition 8
  {
    pinToTurnHigh = ledPin8;
  }
  resetAllLEDs();
  digitalWrite(pinToTurnHigh, HIGH);
}

void resetAllLEDs()
{  
  digitalWrite(ledPin1, LOW);  
  digitalWrite(ledPin2, LOW);  
  digitalWrite(ledPin3, LOW);  
  digitalWrite(ledPin4, LOW);  
  digitalWrite(ledPin5, LOW);  
  digitalWrite(ledPin6, LOW);  
  digitalWrite(ledPin7, LOW);  
  digitalWrite(ledPin8, LOW);
}


user4143: Here's a little tip for you (it has nothing to do with your problem, it's just a good programming method).  This will massively reduce the size of your program.
You have three boolean state variables, and you are comparing the state of all combinations - that's 8 combinations.  If you take each boolean value as 1 bit of a value between 0 and 7 - that is values (as binary) 000, 001, 010, 011, 100, 101, 110, and 111 - then you can use much simpler methods for controlling your LEDs.
For instance, this (untested) code will turn three digital reads into a single number between 0 and 7:
uint8_t value = digitalRead(x) | (digitalRead(y) << 1) | (digitalRead(z) << 2);

x is the least significant bit, and z is the most significant.  So value will now be a value between 0 and 7 representing the state of those three pins.
Now you can use that value variable to decide which pin to turn on.  Here's another trick:  Store you LED pins as an array.  That means, instead of having ledPin1, ledPin2, etc, you just have a list of pin numbers known as ledPin[x]:
const uint8_t ledPin[8] = { 2, 3, 4, 7, 8, 9, 12, 13 };

Now you can use a for loop to iterate though that list and turn on the LED you want:
for (uint8_t i = 0; i < 8; i++) {
    if (i == value) {
        digitalWrite(ledPin[i], HIGH);
    } else {
        digitalWrite(ledPin[i], LOW);
    }
}

In fact, that can be further compressed, since HIGH and LOW are basically truth values (HIGH is 1, or true, and LOW is 0, or false):
for (uint8_t i = 0; i < 8; i++) {
    digitalWrite(ledPin[i], i == value);
}

So your whole program could look like this:
const uint8_t x = A3;    // select the input pin for the switch
const uint8_t y = A4;
const uint8_t z = A5;

const uint8_t ledPin[8] = { 2, 3, 4, 7, 8, 9, 12, 13 };

void setup() {
    for (uint8_t i = 0; i < 8; i++) {
        pinMode(ledPin[i], OUTPUT);
    }
    pinMode(x, INPUT);
    pinMode(y, INPUT);
    pinMode(z, INPUT);
}

void loop() {
    uint8_t value = digitalRead(x) | (digitalRead(y) << 1) | (digitalRead(z) << 2);
    for (uint8_t i = 0; i < 8; i++) {
        digitalWrite(ledPin[i], i == value);
    }
}

Saves a huge amount of typing and also ends up using considerably less Flash memory.

user2881: digitalWrite (ledPin1 = HIGH); should be digitalWrite (ledPin1, HIGH);
PS if ( (x = LOW) && (y = LOW) && (z = LOW)) should be if ( (x == LOW) && (y == LOW) && (z == LOW)). = is for assignment, == is for comparison.

user10794: 
void loop() {
 if ( (x = LOW) && (y = LOW) && (z = LOW))              //condition 1
 {


Apart from the issue of needing == instead of = you are never reading those pins. In fact you are comparing the pin numbers (which will never change), not the data on those pins.
You need:
void loop() {
  if ( (digitalRead (x) == LOW) && 
       (digitalRead (y) == LOW) && 
       (digitalRead (z) == LOW))              //condition 1
    {

... and so on.

This is wrong too, I'm surprised it compiled:

   digitalWrite (ledPin1 = HIGH); 
   digitalWrite (ledPin2 = LOW); 
   digitalWrite (ledPin3 = LOW); 
   digitalWrite (ledPin4 = LOW); 
   digitalWrite (ledPin5 = LOW); 
   digitalWrite (ledPin6 = LOW); 
   digitalWrite (ledPin7 = LOW); 
   digitalWrite (ledPin8 = LOW); 


It should be:
  digitalWrite (ledPin1, HIGH); 
  digitalWrite (ledPin2, LOW); 
  digitalWrite (ledPin3, LOW); 
  digitalWrite (ledPin4, LOW); 
  digitalWrite (ledPin5, LOW); 
  digitalWrite (ledPin6, LOW); 
  digitalWrite (ledPin7, LOW); 
  digitalWrite (ledPin8, LOW); 


when i use digital write i get an error code saying that there are too few arguments.
  ...
   I just dont know why the simulation program is still not lighting the LED

Oh I see, it did not compile. No wonder the LEDs didn't turn on.

11236: <p>I would like to make this code using the Arduino Uno. I am using three on/off switches and based on the truth table would like to turn on one of 8 LEDs. When I use <code>digitalWrite()</code>, I get an error code saying that there are too few arguments. </p>

<p>Here is the code</p>

<pre class="lang-c prettyprint-override"><code>int x = A3;    // select the input pin for the switch
int y = A4;
int z = A5;

int ledPin1 = 2;      // select the pin for the LED
int ledPin2 = 3;
int ledPin3 = 4;
int ledPin4 = 7;
int ledPin5 = 8;
int ledPin6 = 9;
int ledPin7 = 12;
int ledPin8 = 13;

void setup(){

  // declare the ledPin as an OUTPUT:
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
  pinMode(ledPin4, OUTPUT);
  pinMode(ledPin5, OUTPUT);
  pinMode(ledPin6, OUTPUT);
  pinMode(ledPin7, OUTPUT);
  pinMode(ledPin8, OUTPUT);

  pinMode(x, INPUT);
  pinMode(y, INPUT);
  pinMode(z, INPUT);
}

void loop() {

  if ( (x = LOW) &amp;&amp; (y = LOW) &amp;&amp; (z = LOW))              //condition 1
  {
    digitalWrite (ledPin1 = HIGH); 
    digitalWrite (ledPin2 = LOW); 
    digitalWrite (ledPin3 = LOW); 
    digitalWrite (ledPin4 = LOW); 
    digitalWrite (ledPin5 = LOW); 
    digitalWrite (ledPin6 = LOW); 
    digitalWrite (ledPin7 = LOW); 
    digitalWrite (ledPin8 = LOW); 
  }

  if ( (x = LOW) &amp;&amp; (y = LOW) &amp;&amp; (z = HIGH))             //condition 2
  {
    ledPin1 = LOW; 
    ledPin2 = HIGH; 
    ledPin3 = LOW; 
    ledPin4 = LOW; 
    ledPin5 = LOW; 
    ledPin6 = LOW; 
    ledPin7 = LOW; 
    ledPin8 = LOW; 
  }

  if ( (x = LOW) &amp;&amp; (y = HIGH) &amp;&amp; (z = LOW))             //condition 3
  {
    ledPin1 = LOW; 
    ledPin2 = LOW; 
    ledPin3 = HIGH; 
    ledPin4 = LOW; 
    ledPin5 = LOW; 
    ledPin6 = LOW; 
    ledPin7 = LOW; 
    ledPin8 = LOW;
  }

  if ( (x = LOW) &amp;&amp; (y = HIGH) &amp;&amp; (z = HIGH))              //condition 4
  {
    ledPin1 = LOW; 
    ledPin2 = LOW; 
    ledPin3 = LOW; 
    ledPin4 = HIGH; 
    ledPin5 = LOW; 
    ledPin6 = LOW; 
    ledPin7 = LOW; 
    ledPin8 = LOW;
  }

  if ( (x = HIGH) &amp;&amp; (y = LOW) &amp;&amp; (z = LOW))               //condition 5
  {
    ledPin1 = LOW; 
    ledPin2 = LOW; 
    ledPin3 = LOW; 
    ledPin4 = LOW; 
    ledPin5 = HIGH; 
    ledPin6 = LOW; 
    ledPin7 = LOW; 
    ledPin8 = LOW;
  }

  if ( (x = HIGH) &amp;&amp; (y = LOW) &amp;&amp; (z = HIGH))               //condition 6
  {
    ledPin1 = LOW; 
    ledPin2 = LOW; 
    ledPin3 = LOW; 
    ledPin4 = LOW; 
    ledPin5 = LOW; 
    ledPin6 = HIGH; 
    ledPin7 = LOW; 
    ledPin8 = LOW;
  }

  if ( (x = HIGH) &amp;&amp; (y = HIGH) &amp;&amp; (z = LOW))                //condition 7
  {
    ledPin1 = LOW; 
    ledPin2 = LOW; 
    ledPin3 = LOW; 
    ledPin4 = LOW; 
    ledPin5 = LOW; 
    ledPin6 = LOW; 
    ledPin7 = HIGH; 
    ledPin8 = LOW;
  }

  if ( (x = HIGH) &amp;&amp; (y = HIGH) &amp;&amp; (z = HIGH))                //condition 8
  {
    ledPin1 = LOW; 
    ledPin2 = LOW; 
    ledPin3 = LOW; 
    ledPin4 = LOW; 
    ledPin5 = LOW; 
    ledPin6 = LOW; 
    ledPin7 = LOW; 
    ledPin8 = HIGH;
  }
}
</code></pre>

<p><img src="https://i.stack.imgur.com/tabgY.png" alt="Fritzing diagram"></p>
 38174: <p>Since you mentioned you are new to programming, I am posting your own solution modified to work with right things; this code can be optimize to a great extent if you get good at programming; For your benefit, I will post both your approach and a slightly better approach</p>

<p><strong>Your approach:</strong></p>

<pre><code>int x = A3;    // select the input pin for the switch
int y = A4;
int z = A5;

int ledPin1 = 2;      // select the pin for the LED
int ledPin2 = 3;
int ledPin3 = 4;
int ledPin4 = 7;
int ledPin5 = 8;
int ledPin6 = 9;
int ledPin7 = 12;
int ledPin8 = 13;

void setup(){

    // declare the ledPin as an OUTPUT:
    pinMode(ledPin1, OUTPUT);
    pinMode(ledPin2, OUTPUT);
    pinMode(ledPin3, OUTPUT);
    pinMode(ledPin4, OUTPUT);
    pinMode(ledPin5, OUTPUT);
    pinMode(ledPin6, OUTPUT);
    pinMode(ledPin7, OUTPUT);
    pinMode(ledPin8, OUTPUT);

    pinMode(x, INPUT);
    pinMode(y, INPUT);
    pinMode(z, INPUT);
}

void loop() {

    if ( (x = LOW) &amp;&amp; (y = LOW) &amp;&amp; (z = LOW))              //condition 1
    {
        digitalWrite (ledPin1, HIGH); 
        digitalWrite (ledPin2, LOW); 
        digitalWrite (ledPin3, LOW); 
        digitalWrite (ledPin4, LOW); 
        digitalWrite (ledPin5, LOW); 
        digitalWrite (ledPin6, LOW); 
        digitalWrite (ledPin7, LOW); 
        digitalWrite (ledPin8, LOW); 
    }

    if ( (x = LOW) &amp;&amp; (y = LOW) &amp;&amp; (z = HIGH))             //condition 2
    {
        digitalWrite(ledPin1, LOW);  
        digitalWrite(ledPin2, HIGH); 
        digitalWrite(ledPin3, LOW);  
        digitalWrite(ledPin4, LOW);  
        digitalWrite(ledPin5, LOW);  
        digitalWrite(ledPin6, LOW);  
        digitalWrite(ledPin7, LOW);  
        digitalWrite(ledPin8, LOW);  
    }

    if ( (x = LOW) &amp;&amp; (y = HIGH) &amp;&amp; (z = LOW))             //condition 3
    {
        digitalWrite(ledPin1, LOW);  
        digitalWrite(ledPin2, LOW);  
        digitalWrite(ledPin3, HIGH); 
        digitalWrite(ledPin4, LOW);  
        digitalWrite(ledPin5, LOW);  
        digitalWrite(ledPin6, LOW);  
        digitalWrite(ledPin7, LOW);  
        digitalWrite(ledPin8, LOW); 
    }

    if ( (x = LOW) &amp;&amp; (y = HIGH) &amp;&amp; (z = HIGH))              //condition 4
    {
        digitalWrite(ledPin1, LOW);  
        digitalWrite(ledPin2, LOW);  
        digitalWrite(ledPin3, LOW);  
        digitalWrite(ledPin4, HIGH); 
        digitalWrite(ledPin5, LOW);  
        digitalWrite(ledPin6, LOW);  
        digitalWrite(ledPin7, LOW);  
        digitalWrite(ledPin8, LOW); 
    }

    if ( (x = HIGH) &amp;&amp; (y = LOW) &amp;&amp; (z = LOW))               //condition 5
    {
        digitalWrite(ledPin1, LOW);  
        digitalWrite(ledPin2, LOW);  
        digitalWrite(ledPin3, LOW);  
        digitalWrite(ledPin4, LOW);  
        digitalWrite(ledPin5, HIGH); 
        digitalWrite(ledPin6, LOW);  
        digitalWrite(ledPin7, LOW);  
        digitalWrite(ledPin8, LOW); 
    }

    if ( (x = HIGH) &amp;&amp; (y = LOW) &amp;&amp; (z = HIGH))               //condition 6
    {
        digitalWrite(ledPin1, LOW);  
        digitalWrite(ledPin2, LOW);  
        digitalWrite(ledPin3, LOW);  
        digitalWrite(ledPin4, LOW);  
        digitalWrite(ledPin5, LOW);  
        digitalWrite(ledPin6, HIGH); 
        digitalWrite(ledPin7, LOW);  
        digitalWrite(ledPin8, LOW); 
    }

    if ( (x = HIGH) &amp;&amp; (y = HIGH) &amp;&amp; (z = LOW))                //condition 7
    {
        digitalWrite(ledPin1, LOW);  
        digitalWrite(ledPin2, LOW);  
        digitalWrite(ledPin3, LOW);  
        digitalWrite(ledPin4, LOW);  
        digitalWrite(ledPin5, LOW);  
        digitalWrite(ledPin6, LOW);  
        digitalWrite(ledPin7, HIGH); 
        digitalWrite(ledPin8, LOW); 
    }

    if ( (x = HIGH) &amp;&amp; (y = HIGH) &amp;&amp; (z = HIGH))                //condition 8
    {
        digitalWrite(ledPin1, LOW);  
        digitalWrite(ledPin2, LOW);  
        digitalWrite(ledPin3, LOW);  
        digitalWrite(ledPin4, LOW);  
        digitalWrite(ledPin5, LOW);  
        digitalWrite(ledPin6, LOW);  
        digitalWrite(ledPin7, LOW);  
        digitalWrite(ledPin8, HIGH);
    }
}
</code></pre>

<hr>

<p><strong>Slightly better approach:</strong>(better programmers may be able to write even more optimized code)</p>

<pre><code>int x = A3;    // select the input pin for the switch
int y = A4;
int z = A5;

int ledPin1 = 2;      // select the pin for the LED
int ledPin2 = 3;
int ledPin3 = 4;
int ledPin4 = 7;
int ledPin5 = 8;
int ledPin6 = 9;
int ledPin7 = 12;
int ledPin8 = 13;

void setup(){

  // declare the ledPin as an OUTPUT:
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
  pinMode(ledPin4, OUTPUT);
  pinMode(ledPin5, OUTPUT);
  pinMode(ledPin6, OUTPUT);
  pinMode(ledPin7, OUTPUT);
  pinMode(ledPin8, OUTPUT);

  pinMode(x, INPUT);
  pinMode(y, INPUT);
  pinMode(z, INPUT);
}

void loop() {
  int pinToTurnHigh = 2; // just making sure its a valid pin
  if ( (x = LOW) &amp;&amp; (y = LOW) &amp;&amp; (z = LOW))              //condition 1
  {
    pinToTurnHigh = ledPin1;
  }

  if ( (x = LOW) &amp;&amp; (y = LOW) &amp;&amp; (z = HIGH))             //condition 2
  {
    pinToTurnHigh = ledPin2;
  }

  if ( (x = LOW) &amp;&amp; (y = HIGH) &amp;&amp; (z = LOW))             //condition 3
  {
    pinToTurnHigh = ledPin3;
  }

  if ( (x = LOW) &amp;&amp; (y = HIGH) &amp;&amp; (z = HIGH))              //condition 4
  {
    pinToTurnHigh = ledPin4;
  }

  if ( (x = HIGH) &amp;&amp; (y = LOW) &amp;&amp; (z = LOW))               //condition 5
  {
    pinToTurnHigh = ledPin5;
  }

  if ( (x = HIGH) &amp;&amp; (y = LOW) &amp;&amp; (z = HIGH))               //condition 6
  {
    pinToTurnHigh = ledPin6;
  }

  if ( (x = HIGH) &amp;&amp; (y = HIGH) &amp;&amp; (z = LOW))                //condition 7
  {
    pinToTurnHigh = ledPin7;
  }

  if ( (x = HIGH) &amp;&amp; (y = HIGH) &amp;&amp; (z = HIGH))                //condition 8
  {
    pinToTurnHigh = ledPin8;
  }
  resetAllLEDs();
  digitalWrite(pinToTurnHigh, HIGH);
}

void resetAllLEDs()
{  
  digitalWrite(ledPin1, LOW);  
  digitalWrite(ledPin2, LOW);  
  digitalWrite(ledPin3, LOW);  
  digitalWrite(ledPin4, LOW);  
  digitalWrite(ledPin5, LOW);  
  digitalWrite(ledPin6, LOW);  
  digitalWrite(ledPin7, LOW);  
  digitalWrite(ledPin8, LOW);
}
</code></pre>
 4143: <p>Here's a little tip for you (it has nothing to do with your problem, it's just a good programming method).  This will massively reduce the size of your program.</p>

<p>You have three boolean state variables, and you are comparing the state of all combinations - that's 8 combinations.  If you take each boolean value as 1 bit of a value between 0 and 7 - that is values (as binary) 000, 001, 010, 011, 100, 101, 110, and 111 - then you can use much simpler methods for controlling your LEDs.</p>

<p>For instance, this (untested) code will turn three digital reads into a single number between 0 and 7:</p>

<pre><code>uint8_t value = digitalRead(x) | (digitalRead(y) &lt;&lt; 1) | (digitalRead(z) &lt;&lt; 2);
</code></pre>

<p><code>x</code> is the least significant bit, and <code>z</code> is the most significant.  So <code>value</code> will now be a value between 0 and 7 representing the state of those three pins.</p>

<p>Now you can use that <code>value</code> variable to decide which pin to turn on.  Here's another trick:  Store you LED pins as an array.  That means, instead of having <code>ledPin1</code>, <code>ledPin2</code>, etc, you just have a list of pin numbers known as <code>ledPin[x]</code>:</p>

<pre><code>const uint8_t ledPin[8] = { 2, 3, 4, 7, 8, 9, 12, 13 };
</code></pre>

<p>Now you can use a <code>for</code> loop to iterate though that list and turn on the LED you want:</p>

<pre><code>for (uint8_t i = 0; i &lt; 8; i++) {
    if (i == value) {
        digitalWrite(ledPin[i], HIGH);
    } else {
        digitalWrite(ledPin[i], LOW);
    }
}
</code></pre>

<p>In fact, that can be further compressed, since HIGH and LOW are basically truth values (HIGH is 1, or true, and LOW is 0, or false):</p>

<pre><code>for (uint8_t i = 0; i &lt; 8; i++) {
    digitalWrite(ledPin[i], i == value);
}
</code></pre>

<p>So your whole program could look like this:</p>

<pre><code>const uint8_t x = A3;    // select the input pin for the switch
const uint8_t y = A4;
const uint8_t z = A5;

const uint8_t ledPin[8] = { 2, 3, 4, 7, 8, 9, 12, 13 };

void setup() {
    for (uint8_t i = 0; i &lt; 8; i++) {
        pinMode(ledPin[i], OUTPUT);
    }
    pinMode(x, INPUT);
    pinMode(y, INPUT);
    pinMode(z, INPUT);
}

void loop() {
    uint8_t value = digitalRead(x) | (digitalRead(y) &lt;&lt; 1) | (digitalRead(z) &lt;&lt; 2);
    for (uint8_t i = 0; i &lt; 8; i++) {
        digitalWrite(ledPin[i], i == value);
    }
}
</code></pre>

<p>Saves a huge amount of typing and also ends up using considerably less Flash memory.</p>
 2881: <p><code>digitalWrite (ledPin1 = HIGH);</code> should be <code>digitalWrite (ledPin1, HIGH);</code></p>

<p>PS <code>if ( (x = LOW) &amp;&amp; (y = LOW) &amp;&amp; (z = LOW))</code> should be <code>if ( (x == LOW) &amp;&amp; (y == LOW) &amp;&amp; (z == LOW))</code>. <code>=</code> is for assignment, <code>==</code> is for comparison.</p>
 10794: 

<blockquote>
  <p>void loop() {</p>

<pre class="lang-C++ prettyprint-override"><code> if ( (x = LOW) &amp;&amp; (y = LOW) &amp;&amp; (z = LOW))              //condition 1
 {
</code></pre>
</blockquote>

<p>Apart from the issue of needing <code>==</code> instead of <code>=</code> you are never <em>reading</em> those pins. In fact you are comparing the pin <em>numbers</em> (which will never change), not the data on those pins.</p>

<p>You need:</p>

<p>void loop() {</p>

<pre class="lang-C++ prettyprint-override"><code>  if ( (digitalRead (x) == LOW) &amp;&amp; 
       (digitalRead (y) == LOW) &amp;&amp; 
       (digitalRead (z) == LOW))              //condition 1
    {
</code></pre>

<p>... and so on.</p>

<hr>

<p>This is wrong too, I'm surprised it compiled:</p>

<blockquote>
<pre class="lang-C++ prettyprint-override"><code>   digitalWrite (ledPin1 = HIGH); 
   digitalWrite (ledPin2 = LOW); 
   digitalWrite (ledPin3 = LOW); 
   digitalWrite (ledPin4 = LOW); 
   digitalWrite (ledPin5 = LOW); 
   digitalWrite (ledPin6 = LOW); 
   digitalWrite (ledPin7 = LOW); 
   digitalWrite (ledPin8 = LOW); 
</code></pre>
</blockquote>

<p>It should be:</p>

<pre class="lang-C++ prettyprint-override"><code>  digitalWrite (ledPin1, HIGH); 
  digitalWrite (ledPin2, LOW); 
  digitalWrite (ledPin3, LOW); 
  digitalWrite (ledPin4, LOW); 
  digitalWrite (ledPin5, LOW); 
  digitalWrite (ledPin6, LOW); 
  digitalWrite (ledPin7, LOW); 
  digitalWrite (ledPin8, LOW); 
</code></pre>

<blockquote>
  <p>when i use digital write i get an error code saying that there are too few arguments.
  ...
   I just dont know why the simulation program is still not lighting the LED</p>
</blockquote>

<p>Oh I see, it did <em>not</em> compile. No wonder the LEDs didn't turn on.</p>
