Array declaring

For something fairly simple keeps me running into errors. Like; not declared, missing type etc.

Goal is to add an unique name to a second array output. All examples i checked showed arrays with int values, not with chars.

int relayGPIOs[4] = {12, 14, 27, 26};

char relayNames[3] = {"A", "B", "C", "D"};


// Replaces placeholder with button section in your web page
String processor(const String& var){
  //Serial.println(var);
  if(var == "BUTTONPLACEHOLDER"){
    String buttons ="";
    for(int i=1; i<=NUM_RELAYS; i++){
      String relayStateValue = relayState(i);
      buttons+= "<h4>Relay #" + String(i) + " - GPIO " + relayGPIOs[i-1] + relayNames[i-1] + "</h4><label class=\"switch\"><input type=\"checkbox\" onchange=\"toggleCheckbox(this)\" id=\"" + String(i) + "\" "+ relayStateValue +"><span class=\"slider\"></span></label>";
      // buttons+= "<h4>Relay #" + String(i) + " - GPIO " + relayGPIOs[i-1] + "</h4><label class=\"switch\"><input type=\"checkbox\" onchange=\"toggleCheckbox(this)\" id=\"" + String(i) + "\" "+ relayStateValue +"><span class=\"slider\"></span></label>";
    }
    return buttons;
  }
  return String();
}

What am I missing?

char relayNames[3] = {"A", "B", "C", "D"};

That is not an array of chars, but an array of Strings

Use either
char relayNames[3] = {'A, 'B', 'C, 'D'};

or

String relayNames[3] = {"A", "B", "C", "D"};

Hmmmmm......

Capture

That too !

got it running on a 8 channel v3 relay. However, what would be the best GPIO ports to connect the relay.

Currently I have him hooked up on GPIO 12, 14, 27, 26, 25, 33, 32, 35
But it looks like GPIO 26 and 25 connected causing it to fail. Besides that, the ESP32 (38 pin dev.board) does get pretty hot.

It's interesting that pins 25 and 26 are the only two DAC pins. Perhaps that means something in terms of your use.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.