ESP8266 and phi_Interface library - Solved #5

I have been using the phi_interface library.

In one of my projects using a Node MCU V1.0 board alongwith the phi_interfaces for button debouncing.

I have come across a situation where I am doing teh finally integration that pin nos D3 and D4 alone work as expected. But if I try to use pin Nos D5 to D8 I find they report "Touched" status even without touching them .

/*
 * Node MCU Pins available : D3/D4/D5/D6/D7/D8
 * The pins D0/D1/D2/RX/TX are not used as free GPIO(DeepSLeep/Wire /Wire /Serial)
 */

#include <ESP8266WiFi.h>
#include <phi_interfaces.h>

// Define the user push button interface
#define shiftPB  D3
#define incrPB   D4
#define enterPB  D8
#define total_buttons 3
char mapDIN[] = {'H', 'I', 'E'};                           //  This is a list of abbreviated name for each button.
byte pinDIN[] = {shiftPB, incrPB, enterPB};                //  The digital pins connected to the 3 buttons.
phi_button_groups myDIN(mapDIN, pinDIN, total_buttons);
char ValidDIN = '0';

int checkValue;

//$$$$$$$ S E T U P $$$$$$$$$

void setup()
{
  Serial.begin(9600);
}

//############# L O O P #################

void loop()
{
  ValidDIN = myDIN.getKey();

  if (ValidDIN == 'E' ) {                                   // if pins D5, D6, D7, D8 are used then value increments once every 100ms 
    ValidDIN = '0';                                         // irrespective of these pins being grounded. 
    checkValue++;
    Serial.println(checkValue);
  }
  delay(100);
}

Are the input pins held at a known voltage when not pressed or are they floating at an unknown (possibly HIGH, possibly LOW) voltage ?

UKHeliBob:
Are the input pins held at a known voltage when not pressed or are they floating at an unknown (possibly HIGH, possibly LOW) voltage ?

Is it not adequate if the pins are set to input mode ? I thought it automatically invokes the internal pull up.

Anyway tried to insert this statement in the setup() :

digitalWrite(enterPB, HIGH);

Still no luck... possibly the way the NodeMCU pins are configured are different from a simple MCU like Nano or UNo is different. Will read the documentation carefully again...

I thought it automatically invokes the internal pull up.

Then you thought wrong

Although pins default to being inputs I have always thought that it was explicitly better to explicitly set their pinMode() to INPUT_PULLUP if for no other reason than making the code somewhat self documenting.

I wouldn't rely on writing HIGH to the pin to turn on the internal pull-up on other than the AVR boards. Since it's rarely used these days, 3rd party core authors might be unaware of this functionality and not support it in their code. I also think using INPUT_PULLUP makes your code more self-documenting than the less obvious method of setting the pin HIGH.

@UKHeliBob
@pert

Yes that single line "pinMode( xx, INPUT_PULLUP) " did the trick.

Its working fine now !!

Thanks.