0

When I compile this code I get a error: 'currentState' was not declared in this scope.

The code:

enum state: int
 {
  NOTREADY,
  WAITSTARTUP,
  WAITSECRET,
  REVEALSECRET
 }

state currentState; <---- Error

const int BUTTONPIN = 4;
const int ROTARYPIN = A0;

void setup() 
{
  //Open Serial Monitor for debugging purposes
  Serial.begin(9600);

  //Configure the pins
  pinMode(BUTTONPIN, INPUT);
  pinMode(ROTARYPIN, INPUT);

  //Initialise the LCD
  lcd.begin(16, 2);

  //Assume that the current state is wait for start up signal

  currentState=WAITSTARTUP;
}

2 Answers 2

4

You have missing semicolon after the enum:

enum state: int
 {
  NOTREADY,
  WAITSTARTUP,
  WAITSECRET,
  REVEALSECRET
 };  // <-- here 
0

//go the Tools > Boards and check that you have selected the right option of your hardware? your remaining code is almost ok. But remember to add semicolon ";" sign at end every coding line.

  enum state: int{NOTREADY,WAITSTARTUP,WAITSECRET,REVEALSECRET};      
  state currentState; //<---- Error

  const int BUTTONPIN = 4;
  const int ROTARYPIN = A0;

  void setup() 
  {
    //Open Serial Monitor for debugging purposes
    Serial.begin(9600);

    //Configure the pins
    pinMode(BUTTONPIN, INPUT);
    pinMode(ROTARYPIN, INPUT);

    //Initialise the LCD
    lcd.begin(16, 2);

    //Assume that the current state is wait for start up signal

    currentState=WAITSTARTUP;
  }
1
  • I don't see what has board selection to do with this problem. And the solution to the actual problem was already posted.
    – gre_gor
    May 11, 2017 at 13:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.