Testing IC Logic Gates with Arduino

Hi,

I am trying to build a program with Arduino that tests all four gates on a chip simultaneously. When I connect the Arduino to the breadboard and the run the code I always get the message "Error: No Gate Found". What am I doing wrong here? Many thanks if someone can help me.

Here is my code:

int truthValue1;
int truthValue2;
int truthValue3;
int truthValue4;

int inputPin1 = 2;
int inputPin2 = 3;
int inputPin3 = 4;
int inputPin4 = 5;

int outputPin1 = 6;
int outputPin2 = 7;

int led1 = 8;
int led2 = 9;
int led3 = 10;
int led4 = 11;
int ledError = 13;

int x, y, z, w;

int Result;

void setup() {
pinMode(inputPin1, INPUT);
pinMode(inputPin2, INPUT);
pinMode(inputPin3, INPUT);
pinMode(inputPin4, INPUT);

pinMode(outputPin1, OUTPUT);
pinMode(outputPin2, OUTPUT);

pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(ledError, OUTPUT);

Serial.begin(9600);
truthValue1 = 0;
truthValue2 = 0;
truthValue3 = 0;
truthValue4 = 0;

}

void loop() {
truth_Value(false,false);
truthValue1 += (x1);
truthValue2 += (y
1);
truthValue3 += (z1);
truthValue4 += (w
1);

truth_Value(false,true);
truthValue1 += (x2);
truthValue2 += (y
2);
truthValue3 += (z2);
truthValue4 += (w
2);

truth_Value(true,false);
truthValue1 += (x4);
truthValue2 += (y
4);
truthValue3 += (z4);
truthValue4 += (w
4);

truth_Value(true,true);
truthValue1 += (x* 8 );
truthValue2 += (y* 8 );
truthValue3 += (z* 8 );
truthValue4 += (w* 8 );

if((truthValue1 == truthValue2) && (truthValue2 == truthValue3) && (truthValue3 == truthValue4)){
Result = truthValue1;
}else{
Result = 0;
}

switch(Result){
case 6:
Serial.println("This is an XOR gate.");
digitalWrite(led1, truthValue1);
digitalWrite(led2, truthValue2);
digitalWrite(led3, truthValue3);
digitalWrite(led4, truthValue4);
digitalWrite(ledError, LOW);
break;

case 7:
Serial.println("This is an NAND gate.");
digitalWrite(led1, truthValue1);
digitalWrite(led2, truthValue2);
digitalWrite(led3, truthValue3);
digitalWrite(led4, truthValue4);
digitalWrite(ledError, LOW);
break;

case 8:
Serial.println("This is an AND gate.");
digitalWrite(led1, truthValue1);
digitalWrite(led2, truthValue2);
digitalWrite(led3, truthValue3);
digitalWrite(led4, truthValue4);
digitalWrite(ledError, LOW);
break;

case 14:
Serial.println("This is an OR gate.");
digitalWrite(led1, truthValue1);
digitalWrite(led2, truthValue2);
digitalWrite(led3, truthValue3);
digitalWrite(led4, truthValue4);
digitalWrite(ledError, LOW);
break;

default:
Serial.println("ERROR: NO GATE IS FOUND.");
digitalWrite(led1, truthValue1);
digitalWrite(led2, truthValue2);
digitalWrite(led3, truthValue3);
digitalWrite(led4, truthValue4);
digitalWrite(ledError, HIGH);
}
delay(1000);

}

int truth_Value(int output1, int output2){
digitalWrite(outputPin1, output1);
digitalWrite(outputPin2, output2);
delay(500);
int x = digitalRead(inputPin1);
int y = digitalRead(inputPin2);
int z = digitalRead(inputPin3);
int w = digitalRead(inputPin4);

}

What am I doing wrong here?

Not following the advice in Read this before posting a programming question for a start. Unless, of course, your code really has got smileys in it

int truth_Value(int output1, int output2)
{
  digitalWrite(outputPin1, output1);
  digitalWrite(outputPin2, output2);
  delay(500);
  int x = digitalRead(inputPin1);
  int y = digitalRead(inputPin2);
  int z = digitalRead(inputPin3);
  int w = digitalRead(inputPin4);
}

You are creating new local variables named x, y, z, and w and then not using them. I THINK you intended to use the GLOBAL variables of the same names. To do that, take out the 'int' from the start of those four lines.

Also note that you are declaring that function a returning an 'int' value but you don't have a 'return' statement that specifies the 'int' value to return. The function should probably return 'void'.

These are all issues that the compiler will warn you about if you have the warning level turned up.