Hi all
I'm trying to have a Soft_AP server start up on different modes based on the initial switch condition.
And I have boiled my code down to this one simple concept which I just cant wrap my head around .
The AnalogToDigital Example in arduino IDE ... Working as expected :
int pushButton = 12;
int buttonState = 5;// or any random number
void setup() {
Serial.begin(9600);
pinMode(pushButton, INPUT);
}
void loop() {
buttonState = digitalRead(pushButton);
Serial.println(buttonState);//returns correct number based on switch
}
But if I just move the digitalRead command into the initial setup fuction :
int pushButton = 12;
int buttonState = 5;
void setup() {
Serial.begin(9600);
pinMode(pushButton, INPUT);
buttonState = digitalRead(pushButton);
Serial.println(buttonState);// Always prints 0 regardless
}
void loop() {}
It wont even let me save it into another global variable and carry it for later functions.
why is it forbidding me to do a digital read in setup ?
Thank you.