Not tested, but adding the following lines to the sketch should do the trick?!
EDIT: Nope, too quick
#define Button 5 //D1 (GPIO5)
unsigned long previousMillis = 0;
unsigned long interval = 500; //Delays for 500ms before firing again. Change value to your likes.
//void setup() {
pinMode(Button, INPUT_PULLUP); //set GPIO5 'high'
//}
//void loop() {
int buttonState = digitalRead(Button);
if (buttonState == LOW) {
if (state == 0){
if (millis() - previousMillis > interval) {
previousMillis = millis();
setHex();
}
}
else {
if (millis() - previousMillis > interval) {
previousMillis = millis();
allOff();
}
}
}
//}
This should make a wired push-button (GPIO5/ground) work on the NodeMCU. Still untested but works fine with serial output testing.
I'm having one problem with it, though. When I try to compile and upload, I get an error saying:
"exit status 1"
"'max' was not declared in this scope"
And it points to the "x = max(R,G);" line.
I'm just starting out with ESP8266 and Arduino IDE generally, so my attempts to fix this weren't really successful haha
What might be the problem?