Read Multiple Inputs

I wants to develop similar program of Digital input Pullup Serial.

I wants to read 10 Inputs, if any one goes High Output status needs to change.

How to do that..?

The below sample program working fine for one digital input, tried to edit for muktiple inputs read. but not working.

/*
Input Pullup Serial

This example demonstrates the use of pinMode(INPUT_PULLUP). It reads a
digital input on pin 2 and prints the results to the serial monitor.

The circuit:

  • Momentary switch attached from pin 2 to ground
  • Built-in LED on pin 13

Unlike pinMode(INPUT), there is no pull-down resistor necessary. An internal
20K-ohm resistor is pulled to 5V. This configuration causes the input to
read HIGH when the switch is open, and LOW when it is closed.

created 14 March 2012
by Scott Fitzgerald

This example code is in the public domain

*/

void setup() {
//start serial connection
Serial.begin(9600);
//configure pin2 as an input and enable the internal pull-up resistor
pinMode(2, INPUT_PULLUP);
pinMode(13, OUTPUT);

}

void loop() {
//read the pushbutton value into a variable
int sensorVal = digitalRead(2);
//print out the value of the pushbutton
Serial.println(sensorVal);

// Keep in mind the pullup means the pushbutton's
// logic is inverted. It goes HIGH when it's open,
// and LOW when it's pressed. Turn on pin 13 when the
// button's pressed, and off when it's not:
if (sensorVal == HIGH) {
digitalWrite(13, LOW);
} else {
digitalWrite(13, HIGH);
}
}

It will be easier to help if you post the code you tried for multiple inputs.

You should learn about arrays as that will make the program much shorter.

...R

So if any of the 10 inputs are high you want the LED to go high (or low), is that correct?

const int Pins[10] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11};

void setup() {
  for (int i = 0; i < 10; i++) {
    pinMode(Pins[i], INPUT_PULLUP);
  }
}

void loop() {
  boolean sensorVal = false;

  // Set sensorValue to 'true' if any pin reads HIGH
  for (int i = 0; i < 10 && sensorVal == false; i++) {
    sensorVal = digitalRead(Pins[i]);

    //print out the value of the pushbutton
    Serial.print("Pin ");
    Serial.print(Pins[i]);
    Serial.print(": ");
    Serial.println(sensorVal);
  }

  // Set the LED to opposite of 'sensorValue' (on unless at least one pin reads HIGH)
  digitalWrite(13, !sensorVal);
}