Shift Register with NodeMCU

I have been breaking my brain over this one. I have a Shift Register (SN74HC595) that i am trying to use with my Node MCU (ESP8266).

I am able to load and run same code with the Shift Register and the Arduino Nano, but with the NodeMCU the code loads (with no errors) but does not run.

Very strange, and with no errors it’s hard to say why. Here is my code below. Any help would be greatly appreciated.

#include <ESP8266WiFi.h>
#include <WiFiClient.h> 
#include <ESP8266WebServer.h>

#define SHIFT_DATA 6
#define SHIFT_CLK 8
#define SHIFT_LATCH 7

/* Set these to your desired credentials. */
const char *ssid = "MyOldRouter";
const char *password = "SimplePass007";

ESP8266WebServer server(80);

void handleRoot() {
  server.send(200, "text/html", "<h1>You are connected FOOL</h1>");
}

void setAddress(int address) {
  shiftOut(SHIFT_DATA, SHIFT_CLK, MSBFIRST, (address >> 8));
  shiftOut(SHIFT_DATA, SHIFT_CLK, MSBFIRST, address);
  
  digitalWrite(SHIFT_LATCH, LOW);
  digitalWrite(SHIFT_LATCH, HIGH);
  digitalWrite(SHIFT_LATCH, LOW);
}


void setup() {
  //if i take the 3 lines out the code will run without the shifter 
  //vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
   pinMode(SHIFT_DATA, OUTPUT);
   pinMode(SHIFT_CLK, OUTPUT);
   pinMode(SHIFT_LATCH, OUTPUT);
  //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  
  delay(1000);
  Serial.begin(115200);
  Serial.println();
  Serial.print("Configuring access point...");
  /* You can remove the password parameter if you want the AP to be open. */
  WiFi.softAP(ssid, password);

  IPAddress myIP = WiFi.softAPIP();
  Serial.print("AP IP address: ");
  Serial.println(myIP);
  server.on("/", handleRoot);
  server.begin();
  Serial.println("HTTP server started");

    server.on("/on1", [] () {
    server.send(200, "text/plain", "light 1 ON");
    setAddress(1); //pin 1
  });
}

void loop() {
  server.handleClient();
}

Please provide a wiring diagram of your setup.

As the ESP8266 runs on 3V3 you cannot run the shift register at 5V because at 5V a high input signal must be greater than about 3.4V.

Pins 6, 7 and 8 are part of the SPI connection of the flash memory. Using them as outputs means that you can no longer use the memory where your program is saved.

Connect them to the actual pins with the shift register connected. Keep in mind that pin number n corresponds to physical pin GPIOn, not to the pin marked Dn. You can probably use the Dn constants instead of the pin number:

#define SHIFT_DATA D6
#define SHIFT_CLK D8
#define SHIFT_LATCH D7

Pieter