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
You have missing semicolon after the enum:
enum state: int
{
NOTREADY,
WAITSTARTUP,
WAITSECRET,
REVEALSECRET
}; // <-- here
answered May 10, 2017 at 20:43
//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
-
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– gre_gor2017年05月11日 13:27:27 +00:00Commented May 11, 2017 at 13:27
lang-cpp