Arduino School Project

Okay so I have decided to use arduino for a school project... It was obviously a bad idea because I am in way over my head and now I'm just hoping it will work

The project is this- I am making a game. This game will include cards with holes punched out, as well as a card reader. The user will insert the card into the card reader, and the arduino within will use IR LEDs and IR detectors to determine the pattern of holes and no/holes in the card. The user will press a button (A/B/C/D) and if they get it right, green LEDs will flash. If they get it wrong, red LEDs will flash, and a green LED will show the correct answer.

I am getting a ton of error messages when I verify my program, and I hardly know where to begin to fix them. I know it is probably too much to ask from the casual forum browser but any helpful input would be appreciated.. I have not done much programming with arduino, only a little bit of Python. And I am not that good with Python either..

Here is my code, I hope the comments can help you to understand the intended function of the different parts.

const int IR1Pin = A0; //IR sensor #1
const int IR2Pin = A1; //IR sensor #2
const int IR3Pin = A2; //IR sensor #3
const int IR4Pin = A3; //IR sensor #4
const int IR5Pin = A4; //IR sensor #5

const int LEDAcorrectPin = 1; //LED answer A is correct (GREEN LED)
const int LEDBcorrectPin = 2; //LED answer B is correct
const int LEDCcorrectPin = 3; //LED answer C is correct
const int LEDDcorrectPin = 4; //LED answer D is correct

const int LEDAincorrectPin = 5; //LED answer A is incorrect (RED LED)
const int LEDBincorrectPin = 6; //LED answer B is incorrect
const int LEDCincorrectPin = 7; //LED answer C is incorrect
const int LEDDincorrectPin = 8; //LED answer D is incorrect

const int ButtonAPin = 9; //Pushbutton answer A
const int ButtonBPin = 10; //Pushbutton answer B
const int ButtonCPin = 11; //Pushbutton answer C
const int ButtonDPin = 12; //Pushbutton answer D

const int IRLEDPin = 13; //IR LEDs

const int cardbuttonPin = A5; //card in slot?

boolean buttonA = false;
boolean buttonB = false;
boolean buttonC = false;
boolean buttonD = false;

boolean cardin = false;

String answer = "";
String input = "";

void blink() {
	digitalWrite(LEDAcorrectPin, HIGH)
	digitalWrite(LEDBcorrectPin, HIGH)
	digitalWrite(LEDCcorrectPin, HIGH)
	digitalWrite(LEDDcorrectPin, HIGH)
}
	

void setup() {
	pinMode(IR1Pin, INPUT);
	pinMode(IR2Pin, INPUT);
	pinMode(IR3Pin, INPUT);
	pinMode(IR4Pin, INPUT);
	pinMode(IR5Pin, INPUT);

	pinMode(LEDAcorrectPin, OUTPUT);
	pinMode(LEDBcorrectPin, OUTPUT);
	pinMode(LEDCcorrectPin, OUTPUT);
	pinMode(LEDDcorrectPin, OUTPUT);

	pinMode(LEDAincorrectPin, OUTPUT);
	pinMode(LEDBincorrectPin, OUTPUT);
	pinMode(LEDCincorrectPin, OUTPUT);
	pinMode(LEDDincorrectPin, OUTPUT);

	pinMode(ButtonAPin, INPUT);
	pinMode(ButtonBPin, INPUT);
	pinMode(ButtonCPin, INPUT);
	pinMode(ButtonDPin, INPUT);

	pinMode(IRLEDPin, OUTPUT);

	blink();
}

String read(){
        ///This function turns on the array of IR LEDs, then stores
        ///the values of the IR detectors to a string. This string matters
        ///because each individual card will have its own code, which will 
        ///determine what the answer is.
	digitalWrite(IRLEDPin, HIGH);
        boolean IR1 = digitalRead(IR1Pin);
        boolean IR2 = digitalRead(IR2Pin);
        boolean IR3 = digitalRead(IR3Pin);
        boolean IR4 = digitalRead(IR4Pin);
        
        String code = "";
        if (IR1==true){      //if there was an open hole in the card, add a 1
          code += 1;
        }
        else;                //if there was no hole in the card, add a 0
          code += 0;
          
        if (IR2==true){
          code += 1;
        }
        else;
          code += 0;
          
        if (IR2==true){
          code += 1;
        }
        else;
          code += 0;
          
        if (IR2==true){
          code += 1;
        }
        else;
          code += 0;
         
        return code;
}

String answer(code){
        ///This function takes the code read by the IR detectors and 
        ///can tell what the answer is for every code.
	if (code=="00001");
		answer = "A";
	
	
	if (code=="00010");
		answer = "A";
	
	
	if (code=="00011");
		answer = "A";
	
	
	if (code=="00100");
		answer = "A";
	
	
	if (code=="00101");
		answer = "A";
	
	
	if (code=="00110");
		answer = "A";
	
	
	if (code=="00111");
		answer = "A";
	
	
	if (code=="01000");
		answer = "A";
	
	
	if (code=="01001");
		answer = "B";
	
	
	if (code=="01010");
		answer = "B";
	
	
	if (code=="01011");
		answer = "B";
	
	
	if (code=="01100");
		answer = "B";
	
	
	if (code=="01101");
		answer = "B";
	
	
	if (code=="01110");
		answer = "B";
	
	
	if (code=="01111");
		answer = "B";
	
	
	if (code=="10000");
		answer = "B";
	
	
	if (code=="10001");
		answer = "C";
	
	
	if (code=="10010");
		answer = "C";
	
	
	if (code=="10011");
		answer = "C";
	
	
	if (code=="10100");
		answer = "C";
	
	
	if (code=="10101");
		answer = "C";
	
	
	if (code=="10110");
		answer = "C";
	
	
	if (code=="10111");
		answer = "C";
	
	
	if (code=="11000");
		answer = "C";
	
	
	if (code=="11001");
		answer = "D";
	
	
	if (code=="11010");
		answer = "D";
	
	
	if (code=="11011");
		answer = "D";
	
	
	if (code=="11100");
		answer = "D";
	
	
	if (code=="11101");
		answer = "D";
	
	
	if (code=="11110");
		answer = "D";
	
	
	if (code=="11111");
		answer = "D";
	
	
	if (code=="00000");
		answer = "D";
	
	
	return answer
}

String input(){
        ///This function measures to see which button is pressed.
        ///The button is stored in "input"
	buttonA=digitalRead(buttonAPin);
	buttonB=digitalRead(buttonBPin);
	buttonC=digitalRead(buttonCPin);
	buttonD=digitalRead(buttonDPin);
	if(buttonA==true){
		input="A"
        }
	if(buttonB==true){
		input="B"
        }
	if(buttonC==true){
		input="C"
        }
	if(buttonD==true){
		input="D"
        }
	return input
}

void correct(input, answer){
        ///this function compares the correct answer with the user input.
        ///if they are the same, it flashes all the LEDs
        ///If the user got the question wrong, it will flash the correct
        ///answer green and all the others red
	if(input==answer){
		blink();
	}
	
	else{
		if (answer=="A"){
			digitalWrite(LEDAcorrectPin, HIGH);
			digitalWrite(LEDBincorrectPin, HIGH);
			digitalWrite(LEDCincorrectPin, HIGH);
			digitalWrite(LEDDincorrectPin, HIGH);
		}
				
		if (answer=="B"){
			digitalWrite(LEDAincorrectPin, HIGH);
			digitalWrite(LEDBcorrectPin, HIGH);
			digitalWrite(LEDCincorrectPin, HIGH);
			digitalWrite(LEDDincorrectPin, HIGH);
		}
			if (answer=="C"){
			digitalWrite(LEDAincorrectPin, HIGH);
			digitalWrite(LEDBincorrectPin, HIGH);
			digitalWrite(LEDCcorrectPin, HIGH);
			digitalWrite(LEDDincorrectPin, HIGH);
		}
			if (answer=="D"){
			digitalWrite(LEDAincorrectPin, HIGH);
			digitalWrite(LEDBincorrectPin, HIGH);
			digitalWrite(LEDCincorrectPin, HIGH);
			digitalWrite(LEDDcorrectPin, HIGH);
		}
			
	}
}

void main(){
	cardbutton=digitalRead(cardbuttonPin);
	if(cardbutton == HIGH){                  ///if a card is inserted into the slot
		blink();                         ///blink all the LEDs
		read();                          ///read the card
		answer();                        ///use the code to determine what the answer is
		input();                         ///what button did the user press?
		correct();                       ///tell the user if they got it right or not
	}
}

void loop(){
	main();                                  ///run the main function
}
void blink() {
	digitalWrite(LEDAcorrectPin, HIGH)
	digitalWrite(LEDBcorrectPin, HIGH)
	digitalWrite(LEDCcorrectPin, HIGH)
	digitalWrite(LEDDcorrectPin, HIGH)
}

Turning on 4 pins is not blinking them.

Statements need to end with ; Yours don't.

        String code = "";
        if (IR1==true){      //if there was an open hole in the card, add a 1
          code += 1;
        }
        else;                //if there was no hole in the card, add a 0
          code += 0;

0 and 1 are characters, but they are non-printing characters. '0' and '1' are characters, and they are printable.

String answer(code){

All arguments must be typed.

void loop(){
	main();                                  ///run the main function
}

Perhaps main() should call one() which should call two() which should call three() which should call ten() which should do the real work.

Thank you so much! I've got it down to two error messages from about one hundred... I don't know what these mean, so I was wondering if anyone else knows. Also I would appreciate someone proofreading my program to see if it will work for its intended purpose. Thanks!

const int IR1Pin = A0; //IR sensor #1
const int IR2Pin = A1; //IR sensor #2
const int IR3Pin = A2; //IR sensor #3
const int IR4Pin = A3; //IR sensor #4
const int IR5Pin = A4; //IR sensor #5

const int LEDAcorrectPin = 1; //LED answer A is correct (GREEN LED)
const int LEDBcorrectPin = 2; //LED answer B is correct
const int LEDCcorrectPin = 3; //LED answer C is correct
const int LEDDcorrectPin = 4; //LED answer D is correct

const int LEDAincorrectPin = 5; //LED answer A is incorrect (RED LED)
const int LEDBincorrectPin = 6; //LED answer B is incorrect
const int LEDCincorrectPin = 7; //LED answer C is incorrect
const int LEDDincorrectPin = 8; //LED answer D is incorrect



const int IRLEDPin = 13; //IR LEDs



boolean buttonA;
boolean buttonB;
boolean buttonC;
boolean buttonD;



void blink() {
	digitalWrite(LEDAcorrectPin, HIGH);
	digitalWrite(LEDBcorrectPin, HIGH);
	digitalWrite(LEDCcorrectPin, HIGH);
	digitalWrite(LEDDcorrectPin, HIGH);

        delay(100);
        
        digitalWrite(LEDAcorrectPin, LOW);
	digitalWrite(LEDBcorrectPin, LOW);
	digitalWrite(LEDCcorrectPin, LOW);
	digitalWrite(LEDDcorrectPin, LOW);
}
	

void setup() {
	pinMode(IR1Pin, INPUT);
	pinMode(IR2Pin, INPUT);
	pinMode(IR3Pin, INPUT);
	pinMode(IR4Pin, INPUT);
	pinMode(IR5Pin, INPUT);

	pinMode(LEDAcorrectPin, OUTPUT);
	pinMode(LEDBcorrectPin, OUTPUT);
	pinMode(LEDCcorrectPin, OUTPUT);
	pinMode(LEDDcorrectPin, OUTPUT);

	pinMode(LEDAincorrectPin, OUTPUT);
	pinMode(LEDBincorrectPin, OUTPUT);
	pinMode(LEDCincorrectPin, OUTPUT);
	pinMode(LEDDincorrectPin, OUTPUT);


	pinMode(IRLEDPin, OUTPUT);

	blink();
}

String read(){
        ///This function turns on the array of IR LEDs, then stores
        ///the values of the IR detectors to a string. This string matters
        ///because each individual card will have its own code, which will 
        ///determine what the answer is.
	digitalWrite(IRLEDPin, HIGH);
        boolean IR1 = digitalRead(IR1Pin);
        boolean IR2 = digitalRead(IR2Pin);
        boolean IR3 = digitalRead(IR3Pin);
        boolean IR4 = digitalRead(IR4Pin);
        
        String code;
        
        if (IR1==true){      //if there was an open hole in the card, add a 1
          code += "1";
        }
        else;                //if there was no hole in the card, add a 0
          code += "0";
          
        if (IR2==true){
          code += "1";
        }
        else;
          code += "0";
          
        if (IR2==true){
          code += "1";
        }
        else;
          code += "0";
          
        if (IR2==true){
          code += "1";
        }
        else;
          code += "0";
         
        return code;
}

String answer(String code){
        ///This function takes the code read by the IR detectors and 
        ///can tell what the answer is for every code.
	String answer;
        if (code=="00001");
		answer = "A";
	
	
	if (code=="00010");
		answer = "A";
	
	
	if (code=="00011");
		answer = "A";
	
	
	if (code=="00100");
		answer = "A";
	
	
	if (code=="00101");
		answer = "A";
	
	
	if (code=="00110");
		answer = "A";
	
	
	if (code=="00111");
		answer = "A";
	
	
	if (code=="01000");
		answer = "A";
	
	
	if (code=="01001");
		answer = "B";
	
	
	if (code=="01010");
		answer = "B";
	
	
	if (code=="01011");
		answer = "B";
	
	
	if (code=="01100");
		answer = "B";
	
	
	if (code=="01101");
		answer = "B";
	
	
	if (code=="01110");
		answer = "B";
	
	
	if (code=="01111");
		answer = "B";
	
	
	if (code=="10000");
		answer = "B";
	
	
	if (code=="10001");
		answer = "C";
	
	
	if (code=="10010");
		answer = "C";
	
	
	if (code=="10011");
		answer = "C";
	
	
	if (code=="10100");
		answer = "C";
	
	
	if (code=="10101");
		answer = "C";
	
	
	if (code=="10110");
		answer = "C";
	
	
	if (code=="10111");
		answer = "C";
	
	
	if (code=="11000");
		answer = "C";
	
	
	if (code=="11001");
		answer = "D";
	
	
	if (code=="11010");
		answer = "D";
	
	
	if (code=="11011");
		answer = "D";
	
	
	if (code=="11100");
		answer = "D";
	
	
	if (code=="11101");
		answer = "D";
	
	
	if (code=="11110");
		answer = "D";
	
	
	if (code=="11111");
		answer = "D";
	
	
	if (code=="00000");
		answer = "D";
	
	
	return answer;
}

String input(){
        ///This function measures to see which button is pressed.
        ///The button is stored in "input"
        String input;
        
        const int ButtonAPin = 9; //Pushbutton answer A
        const int ButtonBPin = 10; //Pushbutton answer B
        const int ButtonCPin = 11; //Pushbutton answer C
        const int ButtonDPin = 12; //Pushbutton answer D
	
	pinMode(ButtonAPin, INPUT);
	pinMode(ButtonBPin, INPUT);
	pinMode(ButtonCPin, INPUT);
	pinMode(ButtonDPin, INPUT);

        buttonA=digitalRead(ButtonAPin);
	buttonB=digitalRead(ButtonBPin);
	buttonC=digitalRead(ButtonCPin);
	buttonD=digitalRead(ButtonDPin);
	if(buttonA==true){
		input="A";
        }
	if(buttonB==true){
		input="B";
        }
	if(buttonC==true){
		input="C";
        }
	if(buttonD==true){
		input="D";
        }
	return input;
}

void correct(String input, String answer){
        ///this function compares the correct answer with the user input.
        ///if they are the same, it flashes all the LEDs
        ///If the user got the question wrong, it will flash the correct
        ///answer green and all the others red
	if(input==answer){
		blink();
	}
	
	else{
		if (answer=="A"){
			digitalWrite(LEDAcorrectPin, HIGH);
			digitalWrite(LEDBincorrectPin, HIGH);
			digitalWrite(LEDCincorrectPin, HIGH);
			digitalWrite(LEDDincorrectPin, HIGH);
		}
				
		if (answer=="B"){
			digitalWrite(LEDAincorrectPin, HIGH);
			digitalWrite(LEDBcorrectPin, HIGH);
			digitalWrite(LEDCincorrectPin, HIGH);
			digitalWrite(LEDDincorrectPin, HIGH);
		}
			if (answer=="C"){
			digitalWrite(LEDAincorrectPin, HIGH);
			digitalWrite(LEDBincorrectPin, HIGH);
			digitalWrite(LEDCcorrectPin, HIGH);
			digitalWrite(LEDDincorrectPin, HIGH);
		}
			if (answer=="D"){
			digitalWrite(LEDAincorrectPin, HIGH);
			digitalWrite(LEDBincorrectPin, HIGH);
			digitalWrite(LEDCincorrectPin, HIGH);
			digitalWrite(LEDDcorrectPin, HIGH);
		}
			
	}
}

void loop(){
        const int cardbuttonPin = A5; //card in slot?
        String code;
        boolean cardin;
        String input;
        String answer;
        
	cardin=digitalRead(cardbuttonPin);
        
	if(cardin == HIGH){                  ///if a card is inserted into the slot
		blink();                         ///blink all the LEDs
		read();                          ///read the card
		answer(code);                        ///use the code to determine what the answer is
		input();                         ///what button did the user press?
		correct(input, answer);                       ///tell the user if they got it right or not
	}
}

The error messages I'm getting are

cardgame.cpp: In function ‘void loop()’:
cardgame.cpp:337:14: error: no match for call to ‘(String) (String&)’
cardgame.cpp:338:9: error: no match for call to ‘(String) ()’
String input;
        String answer;
     ...
....
....
		answer(code);                        ///use the code to determine what the answer is
		input();

?

Your sketch would be much shorter if you dropped Strings and used simple binary arithmetic and logical operations instead.

	if (code=="00010");

I have not examined your code in detail to find the source of the errors but I did notice this line and many others like it straight away. You need to lose the semi-colon at the end of the line. With it in place your program will not work as intended because the if tests will be ignored.

Thanks! They all now look like

if (code=="00000"){
		answer = "D";
	}

UKHeliBob:

	if (code=="00010");

I have not examined your code in detail to find the source of the errors but I did notice this line and many others like it straight away. You need to lose the semi-colon at the end of the line. With it in place your program will not work as intended because the if tests will be ignored.

The same goes for your else statements.

I probably won't have time to rewrite my whole program to take out the strings, but if I do, could you please point me towards a tutorial or something? I don't really understand what you mean by 'binary arithmetic.' I mean I understand what they mean separately, but I am unsure as to what you really mean.

Your sketch would be much shorter if you dropped Strings and used simple binary arithmetic and logical operations instead.

The same goes for your else statements.

facepalm Thanks, they're all fixed now

Hex4d617474:
I probably won't have time to rewrite my whole program to take out the strings, but if I do, could you please point me towards a tutorial or something? I don't really understand what you mean by 'binary arithmetic.' I mean I understand what they mean separately, but I am unsure as to what you really mean.

Store your detected 'holes' as a binary number.
1111 (15 decimal) means all 4 holes are open
1110 (14 decimal)means only the first 3 holes are open
1001 (9 decimal) means only the first and last holes are open
0000 (0) means no holes are open
To get that number, start with an int, say, holeCount = 0
Add your first 'hole' value (either 1 or 0), multiply holeCount by 2 and add your second 'hole' value.
Multiply by 2 again and add your third 'hole' and multiply by 2 again and add your fourth hole.
You will end up with a number between 0 and 15 in holeCount
You can then use switch case (where you switch on holeCount) to determine your output.

remove ";" after "else" (several places)
like this is OK if (cond) s+="1"; else s+"0";

I might work on the binary arithmetic thing later, right now I just want to make this work so I can use it for my project. The code I have right now looks like this

const int IR1Pin = A0; //IR sensor #1
const int IR2Pin = A1; //IR sensor #2
const int IR3Pin = A2; //IR sensor #3
const int IR4Pin = A3; //IR sensor #4
const int IR5Pin = A4; //IR sensor #5

const int LEDAcorrectPin = 1; //LED answer A is correct (GREEN LED)
const int LEDBcorrectPin = 2; //LED answer B is correct
const int LEDCcorrectPin = 3; //LED answer C is correct
const int LEDDcorrectPin = 4; //LED answer D is correct

const int LEDAincorrectPin = 5; //LED answer A is incorrect (RED LED)
const int LEDBincorrectPin = 6; //LED answer B is incorrect
const int LEDCincorrectPin = 7; //LED answer C is incorrect
const int LEDDincorrectPin = 8; //LED answer D is incorrect



const int IRLEDPin = 13; //IR LEDs



boolean buttonA;
boolean buttonB;
boolean buttonC;
boolean buttonD;



void blink() {
	digitalWrite(LEDAcorrectPin, HIGH);
	digitalWrite(LEDBcorrectPin, HIGH);
	digitalWrite(LEDCcorrectPin, HIGH);
	digitalWrite(LEDDcorrectPin, HIGH);

        delay(100);
        
        digitalWrite(LEDAcorrectPin, LOW);
	digitalWrite(LEDBcorrectPin, LOW);
	digitalWrite(LEDCcorrectPin, LOW);
	digitalWrite(LEDDcorrectPin, LOW);
}
	

void setup() {
	pinMode(IR1Pin, INPUT);
	pinMode(IR2Pin, INPUT);
	pinMode(IR3Pin, INPUT);
	pinMode(IR4Pin, INPUT);
	pinMode(IR5Pin, INPUT);

	pinMode(LEDAcorrectPin, OUTPUT);
	pinMode(LEDBcorrectPin, OUTPUT);
	pinMode(LEDCcorrectPin, OUTPUT);
	pinMode(LEDDcorrectPin, OUTPUT);

	pinMode(LEDAincorrectPin, OUTPUT);
	pinMode(LEDBincorrectPin, OUTPUT);
	pinMode(LEDCincorrectPin, OUTPUT);
	pinMode(LEDDincorrectPin, OUTPUT);


	pinMode(IRLEDPin, OUTPUT);

	blink();
}

String read(){
        ///This function turns on the array of IR LEDs, then stores
        ///the values of the IR detectors to a string. This string matters
        ///because each individual card will have its own code, which will 
        ///determine what the answer is.
	digitalWrite(IRLEDPin, HIGH);
        boolean IR1 = digitalRead(IR1Pin);
        boolean IR2 = digitalRead(IR2Pin);
        boolean IR3 = digitalRead(IR3Pin);
        boolean IR4 = digitalRead(IR4Pin);
        
        String code;
        
        if (IR1==true){      //if there was an open hole in the card, add a 1
          code += "1";
        }
        else{                //if there was no hole in the card, add a 0
          code += "0";
        }
        if (IR2==true){
          code += "1";
        }
        else{
          code += "0";
        }  
        if (IR2==true){
          code += "1";
        }
        else{
          code += "0";
        }  
        if (IR2==true){
          code += "1";
        }
        else{
          code += "0";
        } 
        return code;
}

String answer(String code){
        ///This function takes the code read by the IR detectors and 
        ///can tell what the answer is for every code.
	String answer;
        if (code=="00001"){
		answer = "A";
	}
	
	if (code=="00010"){
		answer = "A";
	}
	
	if (code=="00011"){
		answer = "A";
	}
	
	if (code=="00100"){
		answer = "A";
	}
	
	if (code=="00101"){
		answer = "A";
	}
	
	if (code=="00110"){
		answer = "A";
	}
	
	if (code=="00111"){
		answer = "A";
	}
	
	if (code=="01000"){
		answer = "A";
	}
	
	if (code=="01001"){
		answer = "B";
	}
	
	if (code=="01010"){
		answer = "B";
	}
	
	if (code=="01011"){
		answer = "B";
	}
	
	if (code=="01100"){
		answer = "B";
	}
	
	if (code=="01101"){
		answer = "B";
	}
	
	if (code=="01110"){
		answer = "B";
	}
	
	if (code=="01111"){
		answer = "B";
	}
	
	if (code=="10000"){
		answer = "B";
	}
	
	if (code=="10001"){
		answer = "C";
	}
	
	if (code=="10010"){
		answer = "C";
	}
	
	if (code=="10011"){
		answer = "C";
	}
	
	if (code=="10100"){
		answer = "C";
	}
	
	if (code=="10101"){
		answer = "C";
	}
	
	if (code=="10110"){
		answer = "C";
	}
	
	if (code=="10111"){
		answer = "C";
	}
	
	if (code=="11000"){
		answer = "C";
	}
	
	if (code=="11001"){
		answer = "D";
	}
	
	if (code=="11010"){
		answer = "D";
	}
	
	if (code=="11011"){
		answer = "D";
	}
	
	if (code=="11100"){
		answer = "D";
	}
	
	if (code=="11101"){
		answer = "D";
	}
	
	if (code=="11110"){
		answer = "D";
	}
	
	if (code=="11111"){
		answer = "D";
	}
	
	if (code=="00000"){
		answer = "D";
	}
	
	return answer;
}

String input(){
        ///This function measures to see which button is pressed.
        ///The button is stored in "input"
        String input;
        
        const int ButtonAPin = 9; //Pushbutton answer A
        const int ButtonBPin = 10; //Pushbutton answer B
        const int ButtonCPin = 11; //Pushbutton answer C
        const int ButtonDPin = 12; //Pushbutton answer D
	
	pinMode(ButtonAPin, INPUT);
	pinMode(ButtonBPin, INPUT);
	pinMode(ButtonCPin, INPUT);
	pinMode(ButtonDPin, INPUT);

        buttonA=digitalRead(ButtonAPin);
	buttonB=digitalRead(ButtonBPin);
	buttonC=digitalRead(ButtonCPin);
	buttonD=digitalRead(ButtonDPin);
	if(buttonA==true){
		input="A";
        }
	if(buttonB==true){
		input="B";
        }
	if(buttonC==true){
		input="C";
        }
	if(buttonD==true){
		input="D";
        }
	return input;
}

void correct(String input, String answer){
        ///this function compares the correct answer with the user input.
        ///if they are the same, it flashes all the LEDs
        ///If the user got the question wrong, it will flash the correct
        ///answer green and all the others red
	if(input==answer){
		blink();
	}
	
	else{
		if (answer=="A"){
			digitalWrite(LEDAcorrectPin, HIGH);
			digitalWrite(LEDBincorrectPin, HIGH);
			digitalWrite(LEDCincorrectPin, HIGH);
			digitalWrite(LEDDincorrectPin, HIGH);
		}
				
		if (answer=="B"){
			digitalWrite(LEDAincorrectPin, HIGH);
			digitalWrite(LEDBcorrectPin, HIGH);
			digitalWrite(LEDCincorrectPin, HIGH);
			digitalWrite(LEDDincorrectPin, HIGH);
		}
			if (answer=="C"){
			digitalWrite(LEDAincorrectPin, HIGH);
			digitalWrite(LEDBincorrectPin, HIGH);
			digitalWrite(LEDCcorrectPin, HIGH);
			digitalWrite(LEDDincorrectPin, HIGH);
		}
			if (answer=="D"){
			digitalWrite(LEDAincorrectPin, HIGH);
			digitalWrite(LEDBincorrectPin, HIGH);
			digitalWrite(LEDCincorrectPin, HIGH);
			digitalWrite(LEDDcorrectPin, HIGH);
		}
			
	}
}

void loop(){
        const int cardbuttonPin = A5; //card in slot?
        String code;
        boolean cardin;
        String input;
        String answer;
        
	cardin=digitalRead(cardbuttonPin);
        
	if(cardin == HIGH){                  ///if a card is inserted into the slot
		blink();                         ///blink all the LEDs
		read();                          ///read the card
		answer(code);                        ///use the code to determine what the answer is
		input();                         ///what button did the user press?
		correct(input, answer);                       ///tell the user if they got it right or not
	}
}

And I'm getting the error messages of

cardgame.ino: In function ‘void loop()’:
cardgame.ino:329:14: error: no match for call to ‘(String) (String&)’
cardgame.ino:330:9: error: no match for call to ‘(String) ()’

See reply #3

Alright, I think I've got it; this is what my code looks like now.

const int IR1Pin = A0; //IR sensor #1
const int IR2Pin = A1; //IR sensor #2
const int IR3Pin = A2; //IR sensor #3
const int IR4Pin = A3; //IR sensor #4
const int IR5Pin = A4; //IR sensor #5

const int LEDAcorrectPin = 1; //LED answer A is correct (GREEN LED)
const int LEDBcorrectPin = 2; //LED answer B is correct
const int LEDCcorrectPin = 3; //LED answer C is correct
const int LEDDcorrectPin = 4; //LED answer D is correct

const int LEDAincorrectPin = 5; //LED answer A is incorrect (RED LED)
const int LEDBincorrectPin = 6; //LED answer B is incorrect
const int LEDCincorrectPin = 7; //LED answer C is incorrect
const int LEDDincorrectPin = 8; //LED answer D is incorrect



const int IRLEDPin = 13; //IR LEDs



boolean buttonA;
boolean buttonB;
boolean buttonC;
boolean buttonD;



void blink() {
  digitalWrite(LEDAcorrectPin, HIGH);
  digitalWrite(LEDBcorrectPin, HIGH);
  digitalWrite(LEDCcorrectPin, HIGH);
  digitalWrite(LEDDcorrectPin, HIGH);

  delay(100);

  digitalWrite(LEDAcorrectPin, LOW);
  digitalWrite(LEDBcorrectPin, LOW);
  digitalWrite(LEDCcorrectPin, LOW);
  digitalWrite(LEDDcorrectPin, LOW);
}


void setup() {
  pinMode(IR1Pin, INPUT);
  pinMode(IR2Pin, INPUT);
  pinMode(IR3Pin, INPUT);
  pinMode(IR4Pin, INPUT);
  pinMode(IR5Pin, INPUT);

  pinMode(LEDAcorrectPin, OUTPUT);
  pinMode(LEDBcorrectPin, OUTPUT);
  pinMode(LEDCcorrectPin, OUTPUT);
  pinMode(LEDDcorrectPin, OUTPUT);

  pinMode(LEDAincorrectPin, OUTPUT);
  pinMode(LEDBincorrectPin, OUTPUT);
  pinMode(LEDCincorrectPin, OUTPUT);
  pinMode(LEDDincorrectPin, OUTPUT);


  pinMode(IRLEDPin, OUTPUT);

  blink();
}

int read(){
  ///This function turns on the array of IR LEDs, then stores
  ///the values of the IR detectors to a string. This string matters
  ///because each individual card will have its own code, which will 
  ///determine what the answer is.
  digitalWrite(IRLEDPin, HIGH);
  boolean IR1 = digitalRead(IR1Pin);
  boolean IR2 = digitalRead(IR2Pin);
  boolean IR3 = digitalRead(IR3Pin);
  boolean IR4 = digitalRead(IR4Pin);
  boolean IR5 = digitalRead(IR5Pin);

  int code;

  if (IR1==true){      //if there was an open hole in the card, add a 1
    code += 1;
  }
  else{                //if there was no hole in the card, add a 0
    code += 0;
  }
  code = code * 2;
  
  
  if (IR2==true){
    code += 1;
  }
  else{
    code += 2;
  }  
  code= code * 2;
  
  
  if (IR3==true){
    code += 1;
  }
  else{
    code += 0;
  }  
  code= code*2;
  
  
  if (IR4==true){
    code += 1;
  }
  else{
    code += 0;
  } 
  code = code*2;
  
  if (IR5==true){
    code += 1;
  }
  else{
    code += 0;
  }
  return code;
}

String answer(int code){
  ///This function takes the code read by the IR detectors and 
  ///can tell what the answer is for every code.
  String answer;
  if (code==1){
    answer = "A";
  }

  if (code==2){
    answer = "A";
  }

  if (code==3){
    answer = "A";
  }

  if (code==4){
    answer = "A";
  }

  if (code==5){
    answer = "A";
  }

  if (code==6){
    answer = "A";
  }

  if (code==7){
    answer = "A";
  }

  if (code==8){
    answer = "A";
  }

  if (code==9){
    answer = "B";
  }

  if (code==10){
    answer = "B";
  }

  if (code==11){
    answer = "B";
  }

  if (code==12){
    answer = "B";
  }

  if (code==13){
    answer = "B";
  }

  if (code==14){
    answer = "B";
  }

  if (code==15){
    answer = "B";
  }

  if (code==16){
    answer = "B";
  }

  if (code==17){
    answer = "C";
  }

  if (code==18){
    answer = "C";
  }

  if (code==19){
    answer = "C";
  }

  if (code==20){
    answer = "C";
  }

  if (code==21){
    answer = "C";
  }

  if (code==22){
    answer = "C";
  }

  if (code==23){
    answer = "C";
  }

  if (code==24){
    answer = "C";
  }

  if (code==25){
    answer = "D";
  }

  if (code==26){
    answer = "D";
  }

  if (code==27){
    answer = "D";
  }

  if (code==28){
    answer = "D";
  }

  if (code==29){
    answer = "D";
  }

  if (code==30){
    answer = "D";
  }

  if (code==31){
    answer = "D";
  }

  if (code==32){
    answer = "D";
  }

  return answer;
}

String input(){
  ///This function measures to see which button is pressed.
  ///The button is stored in "input"
  String input;

  const int ButtonAPin = 9; //Pushbutton answer A
  const int ButtonBPin = 10; //Pushbutton answer B
  const int ButtonCPin = 11; //Pushbutton answer C
  const int ButtonDPin = 12; //Pushbutton answer D

  pinMode(ButtonAPin, INPUT);
  pinMode(ButtonBPin, INPUT);
  pinMode(ButtonCPin, INPUT);
  pinMode(ButtonDPin, INPUT);

  buttonA=digitalRead(ButtonAPin);
  buttonB=digitalRead(ButtonBPin);
  buttonC=digitalRead(ButtonCPin);
  buttonD=digitalRead(ButtonDPin);
  if(buttonA==true){
    input="A";
  }
  if(buttonB==true){
    input="B";
  }
  if(buttonC==true){
    input="C";
  }
  if(buttonD==true){
    input="D";
  }
  return input;
}

void correct(String input, String answer){
  ///this function compares the correct answer with the user input.
  ///if they are the same, it flashes all the LEDs
  ///If the user got the question wrong, it will flash the correct
  ///answer green and all the others red
  if(input==answer){
    blink();
  }

  else{
    if (answer=="A"){
      digitalWrite(LEDAcorrectPin, HIGH);
      digitalWrite(LEDBincorrectPin, HIGH);
      digitalWrite(LEDCincorrectPin, HIGH);
      digitalWrite(LEDDincorrectPin, HIGH);
    }

    if (answer=="B"){
      digitalWrite(LEDAincorrectPin, HIGH);
      digitalWrite(LEDBcorrectPin, HIGH);
      digitalWrite(LEDCincorrectPin, HIGH);
      digitalWrite(LEDDincorrectPin, HIGH);
    }
    if (answer=="C"){
      digitalWrite(LEDAincorrectPin, HIGH);
      digitalWrite(LEDBincorrectPin, HIGH);
      digitalWrite(LEDCcorrectPin, HIGH);
      digitalWrite(LEDDincorrectPin, HIGH);
    }
    if (answer=="D"){
      digitalWrite(LEDAincorrectPin, HIGH);
      digitalWrite(LEDBincorrectPin, HIGH);
      digitalWrite(LEDCincorrectPin, HIGH);
      digitalWrite(LEDDcorrectPin, HIGH);
    }

  }
}

void loop(){
  const int cardbuttonPin = A5; //card in slot?
  int code;
  boolean cardin;
  String input;
  String answer;

  cardin=digitalRead(cardbuttonPin);

  if(cardin == HIGH){                ///if a card is inserted into the slot
    blink();                         ///blink all the LEDs
    read();                          ///read the card
    answer(code);                    ///use the code to determine what the answer is
    input();                         ///what button did the user press?
    correct(input, answer);          ///tell the user if they got it right or not
  }
}

However, I'm still getting the error messages

cardgame.ino: In function ‘void loop()’:
cardgame.ino:347:16: error: no match for call to ‘(String) (int&)’
cardgame.ino:348:11: error: no match for call to ‘(String) ()’

Again, see reply #3.

The code compiled with no errors! My thanks to everyone who contributed. I'm just waiting for some parts from RadioShack to come in the mail, then I can test it out.. I'll let everyone know how it goes

const int IR1Pin = A0; //IR sensor #1
const int IR2Pin = A1; //IR sensor #2
const int IR3Pin = A2; //IR sensor #3
const int IR4Pin = A3; //IR sensor #4
const int IR5Pin = A4; //IR sensor #5

const int LEDAcorrectPin = 1; //LED answer A is correct (GREEN LED)
const int LEDBcorrectPin = 2; //LED answer B is correct
const int LEDCcorrectPin = 3; //LED answer C is correct
const int LEDDcorrectPin = 4; //LED answer D is correct

const int LEDAincorrectPin = 5; //LED answer A is incorrect (RED LED)
const int LEDBincorrectPin = 6; //LED answer B is incorrect
const int LEDCincorrectPin = 7; //LED answer C is incorrect
const int LEDDincorrectPin = 8; //LED answer D is incorrect



const int IRLEDPin = 13; //IR LEDs



boolean buttonA;
boolean buttonB;
boolean buttonC;
boolean buttonD;



void blink() {
  digitalWrite(LEDAcorrectPin, HIGH);
  digitalWrite(LEDBcorrectPin, HIGH);
  digitalWrite(LEDCcorrectPin, HIGH);
  digitalWrite(LEDDcorrectPin, HIGH);

  delay(100);

  digitalWrite(LEDAcorrectPin, LOW);
  digitalWrite(LEDBcorrectPin, LOW);
  digitalWrite(LEDCcorrectPin, LOW);
  digitalWrite(LEDDcorrectPin, LOW);
}


void setup() {
  pinMode(IR1Pin, INPUT);
  pinMode(IR2Pin, INPUT);
  pinMode(IR3Pin, INPUT);
  pinMode(IR4Pin, INPUT);
  pinMode(IR5Pin, INPUT);

  pinMode(LEDAcorrectPin, OUTPUT);
  pinMode(LEDBcorrectPin, OUTPUT);
  pinMode(LEDCcorrectPin, OUTPUT);
  pinMode(LEDDcorrectPin, OUTPUT);

  pinMode(LEDAincorrectPin, OUTPUT);
  pinMode(LEDBincorrectPin, OUTPUT);
  pinMode(LEDCincorrectPin, OUTPUT);
  pinMode(LEDDincorrectPin, OUTPUT);


  pinMode(IRLEDPin, OUTPUT);

  blink();
}

int read(){
  ///This function turns on the array of IR LEDs, then stores
  ///the values of the IR detectors to an integer. This integer matters
  ///because each individual card will have its own code, which will 
  ///determine what the answer is.
  digitalWrite(IRLEDPin, HIGH);
  boolean IR1 = digitalRead(IR1Pin);
  boolean IR2 = digitalRead(IR2Pin);
  boolean IR3 = digitalRead(IR3Pin);
  boolean IR4 = digitalRead(IR4Pin);
  boolean IR5 = digitalRead(IR5Pin);

  int code;

  if (IR1==true){      //if there was an open hole in the card, add a 1
    code += 1;
  }
  else{                //if there was no hole in the card, add a 0
    code += 0;
  }
  code = code * 2;
  
  
  if (IR2==true){
    code += 1;
  }
  else{
    code += 2;
  }  
  code= code * 2;
  
  
  if (IR3==true){
    code += 1;
  }
  else{
    code += 0;
  }  
  code= code*2;
  
  
  if (IR4==true){
    code += 1;
  }
  else{
    code += 0;
  } 
  code = code*2;
  
  if (IR5==true){
    code += 1;
  }
  else{
    code += 0;
  }
  return code;
}

int FunctionAnswer(int code){
  ///This function takes the code read by the IR detectors and 
  ///can tell what the answer is for every code.
  int answer;
  if (code==1){
    answer = 1;
  }

  if (code==2){
    answer = 1;
  }

  if (code==3){
    answer = 1;
  }

  if (code==4){
    answer = 1;
  }

  if (code==5){
    answer = 1;
  }

  if (code==6){
    answer = 1;
  }

  if (code==7){
    answer = 1;
  }

  if (code==8){
    answer = 1;
  }

  if (code==9){
    answer = 2;
  }

  if (code==10){
    answer = 2;
  }

  if (code==11){
    answer = 2;
  }

  if (code==12){
    answer = 2;
  }

  if (code==13){
    answer = 2;
  }

  if (code==14){
    answer = 2;
  }

  if (code==15){
    answer = 2;
  }

  if (code==16){
    answer = 2;
  }

  if (code==17){
    answer = 3;
  }

  if (code==18){
    answer = 3;
  }

  if (code==19){
    answer = 3;
  }

  if (code==20){
    answer = 3;
  }

  if (code==21){
    answer = 3;
  }

  if (code==22){
    answer = 3;
  }

  if (code==23){
    answer = 3;
  }

  if (code==24){
    answer = 3;
  }

  if (code==25){
    answer = 4;
  }

  if (code==26){
    answer = 4;
  }

  if (code==27){
    answer = 4;
  }

  if (code==28){
    answer = 4;
  }

  if (code==29){
    answer = 4;
  }

  if (code==30){
    answer = 4;
  }

  if (code==31){
    answer = 4;
  }

  if (code==32){
    answer = 4;
  }

  return answer;
}

int FunctionInput(){
  ///This function measures to see which button is pressed.
  ///The button is stored in "input"
  int input;

  const int ButtonAPin = 9; //Pushbutton answer A
  const int ButtonBPin = 10; //Pushbutton answer B
  const int ButtonCPin = 11; //Pushbutton answer C
  const int ButtonDPin = 12; //Pushbutton answer D

  pinMode(ButtonAPin, INPUT);
  pinMode(ButtonBPin, INPUT);
  pinMode(ButtonCPin, INPUT);
  pinMode(ButtonDPin, INPUT);

  buttonA=digitalRead(ButtonAPin);
  buttonB=digitalRead(ButtonBPin);
  buttonC=digitalRead(ButtonCPin);
  buttonD=digitalRead(ButtonDPin);
  if(buttonA==true){
    input= 1;
  }
  if(buttonB==true){
    input= 2;
  }
  if(buttonC==true){
    input= 3;
  }
  if(buttonD==true){
    input= 4;
  }
  return input;
}

void correct(int input, int answer){
  ///this function compares the correct answer with the user input.
  ///if they are the same, it flashes all the LEDs
  ///If the user got the question wrong, it will flash the correct
  ///answer green and all the others red
  if(input==answer){
    blink();
  }

  else{
    if (answer==1){
      digitalWrite(LEDAcorrectPin, HIGH);
      digitalWrite(LEDBincorrectPin, HIGH);
      digitalWrite(LEDCincorrectPin, HIGH);
      digitalWrite(LEDDincorrectPin, HIGH);
    }

    if (answer==2){
      digitalWrite(LEDAincorrectPin, HIGH);
      digitalWrite(LEDBcorrectPin, HIGH);
      digitalWrite(LEDCincorrectPin, HIGH);
      digitalWrite(LEDDincorrectPin, HIGH);
    }
    if (answer==3){
      digitalWrite(LEDAincorrectPin, HIGH);
      digitalWrite(LEDBincorrectPin, HIGH);
      digitalWrite(LEDCcorrectPin, HIGH);
      digitalWrite(LEDDincorrectPin, HIGH);
    }
    if (answer==4){
      digitalWrite(LEDAincorrectPin, HIGH);
      digitalWrite(LEDBincorrectPin, HIGH);
      digitalWrite(LEDCincorrectPin, HIGH);
      digitalWrite(LEDDcorrectPin, HIGH);
    }

  }
}

void loop(){
  const int cardbuttonPin = A5; //card in slot?
  int code;
  boolean cardin;
  int input;
  int answer;

  cardin=digitalRead(cardbuttonPin);

  if(cardin == HIGH){                ///if a card is inserted into the slot
    blink();                         ///blink all the LEDs
    read();                          ///read the card
    FunctionAnswer(code);                    ///use the code to determine what the answer is
    FunctionInput();                         ///what button did the user press?
    correct(input, answer);          ///tell the user if they got it right or not
  }
}

Hex4d617474:
The code compiled with no errors! My thanks to everyone who contributed. I'm just waiting for some parts from RadioShack to come in the mail, then I can test it out.. I'll let everyone know how it goes

  if (IR1==true){      //if there was an open hole in the card, add a 1
    code += 1;
  }
  else{                //if there was no hole in the card, add a 0
    code += 0;
  }

contracts to:code += IR1;
As true = 1 and false = 0. 1 line instead of 4.
Also, as you're not using IR1 - IR5 anywhere else, you could have:code +=digitalRead(IR1Pin); and get rid of those 5 variables.

Code cannot be 32. It can be anything from 0 to 31 (32 different states). I would not use 0 (all holes closed) as a valid input as it could be that the card is not inserted correctly. You need to increment code somewhere after getting the readings of your IR detectors to get the range 1 to 32, in which case 1 is 'all holes closed' and should throw an error report.

[code}  else{                //if there was no hole in the card, add a 0
    code += 0;
  }

Why bother ?

UKHeliBob:

[code}  else{                //if there was no hole in the card, add a 0

code += 0;
  }


Why bother ?

.....good question..

Okay I changed up my code, but now the LEDs wont blink, not even once for startup

const int IR1Pin = A0; //IR sensor #1
const int IR2Pin = A1; //IR sensor #2
const int IR3Pin = A2; //IR sensor #3
const int IR4Pin = A3; //IR sensor #4
const int IR5Pin = A4; //IR sensor #5

const int LEDAcorrectPin = 1; //LED answer A is correct (GREEN LED)
const int LEDBcorrectPin = 2; //LED answer B is correct
const int LEDCcorrectPin = 3; //LED answer C is correct
const int LEDDcorrectPin = 4; //LED answer D is correct

const int LEDAincorrectPin = 5; //LED answer A is incorrect (RED LED)
const int LEDBincorrectPin = 6; //LED answer B is incorrect
const int LEDCincorrectPin = 7; //LED answer C is incorrect
const int LEDDincorrectPin = 8; //LED answer D is incorrect



const int IRLEDPin = 13; //IR LEDs



boolean buttonA;
boolean buttonB;
boolean buttonC;
boolean buttonD;



void blink() {
  digitalWrite(LEDAcorrectPin, HIGH);
  digitalWrite(LEDBcorrectPin, HIGH);
  digitalWrite(LEDCcorrectPin, HIGH);
  digitalWrite(LEDDcorrectPin, HIGH);

  delay(100);

  digitalWrite(LEDAcorrectPin, LOW);
  digitalWrite(LEDBcorrectPin, LOW);
  digitalWrite(LEDCcorrectPin, LOW);
  digitalWrite(LEDDcorrectPin, LOW);
}


void setup() {
  pinMode(IR1Pin, INPUT);
  pinMode(IR2Pin, INPUT);
  pinMode(IR3Pin, INPUT);
  pinMode(IR4Pin, INPUT);
  pinMode(IR5Pin, INPUT);

  pinMode(LEDAcorrectPin, OUTPUT);
  pinMode(LEDBcorrectPin, OUTPUT);
  pinMode(LEDCcorrectPin, OUTPUT);
  pinMode(LEDDcorrectPin, OUTPUT);

  pinMode(LEDAincorrectPin, OUTPUT);
  pinMode(LEDBincorrectPin, OUTPUT);
  pinMode(LEDCincorrectPin, OUTPUT);
  pinMode(LEDDincorrectPin, OUTPUT);


  pinMode(IRLEDPin, OUTPUT);

  blink();
}

int read(){
  ///This function turns on the array of IR LEDs, then stores
  ///the values of the IR detectors to an integer. This integer matters
  ///because each individual card will have its own code, which will 
  ///determine what the answer is.
  digitalWrite(IRLEDPin, HIGH);
  boolean IR1 = digitalRead(IR1Pin);
  boolean IR2 = digitalRead(IR2Pin);
  boolean IR3 = digitalRead(IR3Pin);
  boolean IR4 = digitalRead(IR4Pin);
  boolean IR5 = digitalRead(IR5Pin);

  int code;

  code += IR1;
  code = code * 2;
  
  code += IR2;  
  code= code * 2;
   
  code += IR3;  
  code= code*2;
  
  code += IR4; 
  code = code*2;
  
  code += IR5;
  return code;
}

int FunctionAnswer(int code){
  ///This function takes the code read by the IR detectors and 
  ///can tell what the answer is for every code.
  int answer;
  if (code==1){
    answer = 1;
  }

  if (code==2){
    answer = 1;
  }

  if (code==3){
    answer = 1;
  }

  if (code==4){
    answer = 1;
  }

  if (code==5){
    answer = 1;
  }

  if (code==6){
    answer = 1;
  }

  if (code==7){
    answer = 1;
  }

  if (code==8){
    answer = 2;
  }

  if (code==9){
    answer = 2;
  }

  if (code==10){
    answer = 2;
  }

  if (code==11){
    answer = 2;
  }

  if (code==12){
    answer = 2;
  }

  if (code==13){
    answer = 2;
  }

  if (code==14){
    answer = 2;
  }

  if (code==15){
    answer = 3;
  }

  if (code==16){
    answer = 3;
  }

  if (code==17){
    answer = 3;
  }

  if (code==18){
    answer = 3;
  }

  if (code==19){
    answer = 3;
  }

  if (code==20){
    answer = 3;
  }

  if (code==21){
    answer = 3;
  }

  if (code==22){
    answer = 3;
  }

  if (code==23){
    answer = 4;
  }

  if (code==24){
    answer = 4;
  }

  if (code==25){
    answer = 4;
  }

  if (code==26){
    answer = 4;
  }

  if (code==27){
    answer = 4;
  }

  if (code==28){
    answer = 4;
  }

  if (code==29){
    answer = 4;
  }

  if (code==30){
    answer = 4;
  }

  return answer;
}

int FunctionInput(){
  ///This function measures to see which button is pressed.
  ///The button is stored in "input"
  int input;

  const int ButtonAPin = 9; //Pushbutton answer A
  const int ButtonBPin = 10; //Pushbutton answer B
  const int ButtonCPin = 11; //Pushbutton answer C
  const int ButtonDPin = 12; //Pushbutton answer D

  pinMode(ButtonAPin, INPUT);
  pinMode(ButtonBPin, INPUT);
  pinMode(ButtonCPin, INPUT);
  pinMode(ButtonDPin, INPUT);

  buttonA=digitalRead(ButtonAPin);
  buttonB=digitalRead(ButtonBPin);
  buttonC=digitalRead(ButtonCPin);
  buttonD=digitalRead(ButtonDPin);
  if(buttonA==true){
    input= 1;
  }
  if(buttonB==true){
    input= 2;
  }
  if(buttonC==true){
    input= 3;
  }
  if(buttonD==true){
    input= 4;
  }
  return input;
}

void correct(int input, int answer){
  ///this function compares the correct answer with the user input.
  ///if they are the same, it flashes all the LEDs
  ///If the user got the question wrong, it will flash the correct
  ///answer green and all the others red
  if(input==answer){
    blink();
  }

  else{
    if (answer==1){
      digitalWrite(LEDAcorrectPin, HIGH);
      digitalWrite(LEDBincorrectPin, HIGH);
      digitalWrite(LEDCincorrectPin, HIGH);
      digitalWrite(LEDDincorrectPin, HIGH);
    }

    if (answer==2){
      digitalWrite(LEDAincorrectPin, HIGH);
      digitalWrite(LEDBcorrectPin, HIGH);
      digitalWrite(LEDCincorrectPin, HIGH);
      digitalWrite(LEDDincorrectPin, HIGH);
    }
    if (answer==3){
      digitalWrite(LEDAincorrectPin, HIGH);
      digitalWrite(LEDBincorrectPin, HIGH);
      digitalWrite(LEDCcorrectPin, HIGH);
      digitalWrite(LEDDincorrectPin, HIGH);
    }
    if (answer==4){
      digitalWrite(LEDAincorrectPin, HIGH);
      digitalWrite(LEDBincorrectPin, HIGH);
      digitalWrite(LEDCincorrectPin, HIGH);
      digitalWrite(LEDDcorrectPin, HIGH);
    }

  }
}

void loop(){
  int code;
  int input;
  int answer;

  read();                          ///read the card
  if (code < 31 && code > 0){         
  FunctionAnswer(code);                    ///use the code to determine what the answer is
  FunctionInput();                         ///what button did the user press?
  correct(input, answer);    ///tell the user if they got it right or not
  }
  delay(100);
}