Store different digital inputs in 1 array

Hi, I am trying to read 10 digital inputs, and I'm storing these in val1, val2, ...val10. If eg. val1=LOW I want to store "1" in an array, if val2=LOW I want to store "2", etc. I have worked with arrays from one analog input that store different values, and now I don't know how to solve this... Can anyone help me?

As I read your message, you have 10 pins you want to read into an array.

There are a couple of ways to do this. The simplest might be to place the pin numbers themselves into an array, then read and store them into another array all in one step.

// Pin decls:

   //  You can declare your pin numbers randomly,  sequentially, or any way you want.

  int val[10] = {4,11,6,5,7,0,3,8,2,1}; 


// Var decls:

  byte res[10];


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

loop()
{
   int i;

   while(1)
      for (i=0; i<10; i++)
         res[i] = digitalRead(val[i]);

}

HTH (or, at least, I hope this answers what you were asking...)

TJ

Oops... I just read your message a different way. Are you saying that only one of the 10 pins will be low at any given time, and you want to store that pin's identity into an array?

Again, simple code, but please tightly define your problem and I'll give you a proper solution. If I try it again right now, I'd just be shotgunning your problem.

TJ