A place users can post their projects. If you have a small project and would like your own dedicated place to post and have others chat about it then this is your spot.

User avatar
By eqsOne
#62392 This should add a push button to GPIO5, using the on/off url's like suggested by DaPeace. Sometimes I tend to think more complicated than it actually is, I guess.

Not tested, but adding the following lines to the sketch should do the trick?!

Code: Select all
EDIT: Nope, too quick

Last edited by eqsOne on Mon Feb 13, 2017 2:53 pm, edited 1 time in total.
User avatar
By eqsOne
#62513 Added some delay to the switch comands, without it fired too quick. This kind of delay should also not affect the rest of the loop:

Code: Select all
#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.
User avatar
By thecoder
#62859 Thanks so much for making this.
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?