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;
}
asked May 10, 2017 at 20:29

2 Answers 2

4

You have missing semicolon after the enum:

enum state: int
 {
 NOTREADY,
 WAITSTARTUP,
 WAITSECRET,
 REVEALSECRET
 }; // <-- here 
answered May 10, 2017 at 20:43
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;
 }
goddland_16
5295 silver badges14 bronze badges
answered May 11, 2017 at 5:48
1
  • I don't see what has board selection to do with this problem. And the solution to the actual problem was already posted. Commented May 11, 2017 at 13:27

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.