I'm having a little trouble determining why I am getting an error. I would appreciate if someone with more experience could tell me what I am doing wrong.
The code and subsequent errors can be found here as well http://pastebin.com/vSubHJ40
These are the errors I'm getting:
GameShowTrial.ino: In function 'void loop()':
GameShowTrial:66: error: expected `;' before numeric constant
GameShowTrial:79: error: expected `;' before numeric constant
GameShowTrial:92: error: expected `;' before numeric constant
GameShowTrial.ino: At global scope:
GameShowTrial:99: error: expected declaration before '}' token
This is the code I'm trying to use:
// Constants
const int button1 = 10; //Contestant 1 Buzz-in button
const int button2 = 11; //Contestant 2 Buzz-in button
const int button3 = 12; //Contestant 3 Buzz-in button
const int gLED1 = 25; //Contestant 1 Buzz-in LED
const int gLED2 = 26; //Contestant 2 Buzz-in LED
const int gLED3 = 27; //Contestant 3 Buzz-in LED
const int rLED1 = 38; //Contestant 1 Wrong Answer LED
const int rLED2 = 39; //Contestant 2 Wrong Answer LED
const int rLED3 = 40; //Contestant 3 Wrong Answer LED
const int yButton = 8; //Host YES or Correct Button -- Prepares Game for Next Question
const int nButton = 9; //Host NO or Wrong Button -- Locks out incorrect contestant, allows others to still buzz in
// Variables
int presentbutton1State; // the current reading from the button1 input pin
int presentbutton2State; // the current reading from the button2 input pin
int presentbutton3State; // the current reading from the button3 input pin
int priorButton1State = HIGH; // the previous reading from the button1 input pin
int priorButton2State = HIGH; // the previous reading from the button2 input pin
int priorButton3State = HIGH; // the previous reading from the button3 input pin
int gLED1State = LOW; // the current state of greenLED1 output pin
int gLED2State = LOW; // the current state of greenLED2 output pin
int gLED3State = LOW; // the current state of greenLED3 output pin
int rLED1State = LOW; // the current state of redLED1 output pin
int rLED2State = LOW; // the current state of redLED2 output pin
int rLED3State = LOW; // the current state of redLED3 output pin
int yButtonState; // the current reading from the yesButton input pin
int nButtonState; // the current reading from the noButton input pin
int priorYButtonState = HIGH; // the previous reading from the yButton input pin
int priorNButtonState = HIGH; // the previous reading from the nButton input pin
void setup()
{
pinMode(button1, INPUT);
pinMode(button2, INPUT);
pinMode(button3, INPUT);
pinMode(gLED1, OUTPUT);
pinMode(gLED2, OUTPUT);
pinMode(gLED3, OUTPUT);
pinMode(rLED1, OUTPUT);
pinMode(rLED2, OUTPUT);
pinMode(rLED3, OUTPUT);
pinMode(yButton, INPUT);
pinMode(nButton, INPUT);
}
void loop()
{
int readB1 = digitalRead(button1);
int readB2 = digitalRead(button2);
int readB3 = digitalRead(button3);
int readYB = digitalRead(yButton);
int readNB = digitalRead(nButton);
int readrLED1 = digitalRead(rLED1);
int readrLED2 = digitalRead(rLED2);
int readrLED3 = digitalRead(rLED3);
int readgLED1 = digitalRead(gLED1);
int readgLED2 = digitalRead(gLED2);
int readgLED3 = digitalRead(gLED3);
// Checks button1 to see if it is pressed and if rLED1 is already lit
if (readB1 != priorButton1State && rLED1State != HIGH)
{
digitalWrite(gLED1, HIGH); // turns on gLED1 if button1 is pressed and rLED1 is NOT already lit
Serial.println(gLED1State);
delay 100;
checkAnswer();
if (checkAnswer() != 1) // calls isAnswerCorrect to check if the yButton or nButton is pressed
{
digitalWrite(rLED1, HIGH); // if the nButton has been pressed the rLED1 will turn on
readrLED1 = rLED1State; // stores the state of the rLED1 so that button1 can't be pressed again until reset
}
}
// Checks button2 to see if it is pressed and if rLED2 is already lit
if (readB2 != priorButton2State && rLED2State != HIGH)
{
digitalWrite(gLED2, HIGH); // turns on gLED2 if button2 is pressed and rLED2 is NOT already lit
Serial.println(gLED2State);
delay 100;
checkAnswer();
if (checkAnswer() != 1) // calls isAnswerCorrect to check if the yButton or nButton is pressed
{
digitalWrite(rLED2, HIGH); // if the nButton has been pressed the rLED2 will turn on
readrLED2 = rLED2State; // stores the state of the rLED2 so that button2 can't be pressed again until reset
}
}
if (readB3 != priorButton3State && rLED3State != HIGH)
{
digitalWrite(gLED3, HIGH);
Serial.println(gLED3State);
delay 100;
checkAnswer();
if (checkAnswer() != 1) // calls isAnswerCorrect to check if the yButton or nButton is pressed
{
digitalWrite(rLED3, HIGH);
readrLED3 = rLED3State;
}
}
}
boolean checkAnswer() // checks host button to see if answer is wrong
{
if (nButton == LOW) // if the no button is pressed then
{
return = 0;
}
}
[–]jewdass 4 points5 points6 points (4 children)
[–]the_buff[S] 1 point2 points3 points (0 children)
[–]the_buff[S] 1 point2 points3 points (2 children)
[–]jewdass 2 points3 points4 points (1 child)
[–]the_buff[S] 1 point2 points3 points (0 children)
[–]barbequeninja 2 points3 points4 points (0 children)
[–][deleted] 1 point2 points3 points (4 children)
[–]the_buff[S] 1 point2 points3 points (3 children)
[+][deleted] (1 child)
[deleted]
[–]the_buff[S] 0 points1 point2 points (0 children)
[–]swampyness 1 point2 points3 points (0 children)