First Arduino Project: Help!

I apologize in advance if I'm not specific enough. I have a chunk of the code my project needs figured out, there's just some parts that are escaping me.

I want to send a digital signal out on one of 8 output pins, then scan input pins, expecting results in a fashion similar to:

HIGH LOW LOW LOW LOW LOW LOW LOW (signal on pin 1)

After the program has cycled through all 8 output pins, I will have a pattern of 64 (if my sleep deprived, over caffeinated math is correct) HIGH/LOW readings. Here's what I would like to be able to do:

Store each HIGH/LOW reading in a single array (we'll call it "test"), and then compare this array to one of 3 or 4 (maybe more) pre determined arrays and generate a pass/fail indication, then clear the "test" array with a reset buttin which would cause the program to restart.

There is more to my program, and I'll add that to my thread as needed, but this is the main portion that I will need help with.

I just need help with the array portion, I've got the pin assignments, commands to activate the pins down.

If you've only got eight pins, why do you need an array?
Wouldn't a single byte work just as well?

AWOL:
If you've only got eight pins, why do you need an array?
Wouldn't a single byte work just as well?

Let's say that output pin 1 goes HIGH, each of the 8 input pins can be HIGH or LOW. Multiply that by 8 pins and you'd end up with something like this (random in this case as it's just an example)

HIGH LOW LOW LOW LOW LOW LOW LOW (pin 1)
HIGH LOW LOW HIGH LOW LOW LOW LOW (pin 2)
HIGH LOW LOW LOW LOW LOW LOW LOW (pin 3)
HIGH LOW LOW LOW HIGH LOW LOW LOW (pin 4)
HIGH LOW LOW LOW LOW LOW LOW LOW (pin 5)
HIGH LOW LOW LOW LOW LOW LOW LOW (pin 6)
HIGH LOW LOW LOW LOW LOW LOW LOW (pin 7)
HIGH LOW LOW LOW LOW LOW LOW LOW (pin 8)

I wanted to compare this to an array where :

HIGH LOW LOW LOW LOW LOW LOW LOW (pin 1)
LOW HIGH LOW LOW LOW LOW LOW LOW (pin 2)
And so on...

I found the following snippet of code, posted by Mem in http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1252971110

Looks like might be able to adapt it for my needs and it should compact program size a bit from the way I was originally doing it. Each pin would result in a byte representing the state of each of the 8 pinput pins. AWOL, looks like you were right. If each output pin, and the switch states for each input pin (8 input states for each output state) results in a case, could I do an if/then type statement combining them (if case1, case2...case 8, then the test passes as X)?

// this code assumes that pull-down resistors are used - invert the state if using pull-ups.

int pins[] = {2,3,5,7,8,9}; // array holding the pins connected to switches
int number_of_pins = sizeof(pins)/ sizeof(pins[0]);  // determines how many pins in the above array

int switchStates = 0; // this will hold a bitmask of switch states

void setup()
{
  Serial.begin(9600);
}

void loop()
{
    // save the switch states as bits in the variable switchStates
    for(int i=0; i < number_of_pins; i++)
    {
	// set bits in switchState to represent the state of the switches
	int state = digitalRead( pins[i]);    
	bitWrite(switchStates, i, state);
    }
    
    switch (switchStates)
    {
      // test for some combinations of switches we care about
	case  B000001: Serial.println("the first switch (pin 2) is pressed"); break;
	case  B000101: Serial.println("switches on pins 2 and 5 are pressed"); break;
	case  B111111: Serial.println("all switches are pressed"); break;
    }
    showFlags();  
    delay(1000);
}

// reports flags that are set to see how the switchStates variable is used
void showFlags()
{
    Serial.println(switchStates, BIN);
    for(int sw = 0; sw < number_of_pins; sw++)
    {
	Serial.print("Switch ");
	Serial.print(sw);
	if( bitRead(switchStates, sw) == true)
	   Serial.println(" is pressed ");
	else  
	   Serial.println(" is not pressed");
    }
    Serial.println();
}

could I do an if/then type statement combining them (if case1, case2...case 8, then the test passes as X)?

Or you could do it with a simple lookup table.

I don't really quite know enough about the programming language to understand that.

You've got eight bits of data.
Eight bits allows 256 unique combinations, so an array of 32 bytes represents the 256 combinations, with each bit representing PASS/FAIL.
Your eight input bits reference a single bit in the array,and the bit represents either PASS or FAIL.
Simple arithmetic will give you which byte/bit to access.

A pattern of all the outputs can stored in a single int variable.

When you want X statusses to be stored, just declare an array : int portStatus[X]

portStatus[0] = 0b01010111;
portStatus[1] = 0b11110111;

Retrieve with:

statusNeeded = portStatus[7];

255 = 0b11111111
0b11111111 = 255
0b11111110 = 254
etc..

This way you can manipulate every value with binary math.

See Arduino Playground - BitMath

Just to clarify:

0b11111111 represent 8 pins and it's status; all on
0b00000000 all off
0b00000001 pin 1 on the rest off

A pattern of all the outputs can stored in a single int variable.

sp. "byte variable"