Bad code maybe

Can someone look at this and see if you can see what the heck i’m missing.
I just want to control 4 relays
board type is lOlin vr3
i have flashed with the blinky test and it is working fine
when i goto to compile this sketch i get all kinds of unexpected errors.

#include <ESP8266WiFi.h>
     
    const char* ssid     = "******";
    const char* password = "*******";     

    int wifiStatus;

    #define D5
    #define D6
    #define D7
    #define D8
     
    void setup() {
      
      Serial.begin(115200);\
      delay(200);



  // LED
 pinMode(D5, OUTPUT)
  digitalWrite(D5, HIGH)

  pinMode(D6, OUTPUT)
  digitalWrite(D6, HIGH)
  
 pinMode(D7, OUTPUT)
  digitalWrite(D7, HIGH)


 pinMode(D8, OUTPUT)
  digitalWrite(D8, HIGH)

        
    if ( (strcmp(device_name, D5) == 0) ) {
      // this just sets a variable that the main loop() does something about
      Serial.println("RELAY 1 switched by Alexa");
      //digitalWrite(RELAY_PIN_1, !digitalRead(RELAY_PIN_1));
      if (state) {
        digitalWrite(D5, LOW)
      } else {
        digitalWrite(D51, HIGH)
      }
    }
    if ( (strcmp(device_name, D6) == 0) ) {
      // this just sets a variable that the main loop() does something about
      Serial.println("RELAY 2 switched by Alexa");
      if (state) {
        digitalWrite(D6, LOW)
      } else {
        digitalWrite(D6, HIGH)
      }
    }
      if ( (strcmp(device_name, D7) == 0) ) {
      // this just sets a variable that the main loop() does something about
      Serial.println("RELAY 3 switched by Alexa");
      if (state) {
        digitalWrite(D7, LOW)
      } else {
        digitalWrite(D7, HIGH)
      }
    }
      if ( (strcmp(device_name, D8) == 0) ) {
      // this just sets a variable that the main loop() does something about
      Serial.println("RELAY 4 switched by Alexa");
       //digitalWrite(RELAY_PIN_4, !digitalRead(RELAY_PIN_4));
      if (state) {
        digitalWrite(D8, LOW)
      } else {
        digitalWrite(D8, HIGH)
      }
    }
  });

}

void loop() {


  static unsigned long last = millis();
  if (millis() - last > 5000) {
    last = millis();
    Serial.printf("[MAIN] Free heap: %d bytes\n", ESP.getFreeHeap());
  }
    
 
 
}

void loop() {
  // put your main code here, to run repeatedly:

}

paulgilford:
when i goto to compile this sketch i get all kinds of unexpected errors.

If the errors had been expected you probably would not have tried compiling the program :slight_smile:

Please post the actual error message.

Oftentimes solving the problem highlighted by the first error message also clears a bunch of others.

...R

#define D5

Why are you redefining D5 as empty?

and Why ? two Loops?? :frowning:

And should it be the PIN number of à led

 pinMode(D5, OUTPUT)
  digitalWrite(D5, HIGH);

Or is it a cString

 if ( (strcmp(device_name, D5) == 0) ) {

Feels very weird... you can drop the maybe, it is indeed bad code :wink: