Array help

This is just a snippet of my application to zoom in on the problem.

What I would like to do is change a few variables up top and have that configure the stuff down below. That way I can keep just one code base for a dozen devices. But maybe I don’t really understand how variables work. I have spent about two weeks on this and have tried about a million variations that I have found online. The current error is:
/Users/jabbott/Documents/Arduino/sketch_feb13a/sketch_feb13a.ino: In function ‘void setup()’:
sketch_feb13a:18:30: error: invalid conversion from ‘char’ to ‘const char*’ [-fpermissive]
Blynk.begin(auth, ssid, pass);

But I have had lots of errors. You should be able to figure out what I am trying to do below even if it doesn’t compile.

–ja

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

#define ROOM 1
#define LOCATION 1

const char my_ssid[] = { 'The Abbotts', 'Flints_Realm', 'Horners Corner' } ;
const char my_pass[] = { 'th3XXXXXX, 'PupXXXXXX', 'mapXXXXX' };
const char poss_auth[] = { 'CGlXXXXXXXLmxTZvqPoa4YGL3TDoQ6S', '0cpCeyQIGXXXXXX5cB0u9_SLDuCD', 'Emiw5PYmeXpXXXXX0kSEzt91nyadv' };

void setup() {
  
  char auth = poss_auth[ROOM];
  char ssid = my_ssid[LOCATION];
  char pass = my_pass[LOCATION];
  
 Blynk.begin(auth, ssid, pass);
 
}

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

}

#define ROOM 1
#define LOCATION 1

char* my_ssid[] = { "The Abbotts", "Flints_Realm", "Horners Corner" } ;// ==> double quotes
char* my_pass[] = { "th3XXXXXX", "PupXXXXXX", "mapXXXXX" };
char* poss_auth[] = { "CGlXXXXXXXLmxTZvqPoa4YGL3TDoQ6S", "0cpCeyQIGXXXXXX5cB0u9_SLDuCD", "Emiw5PYmeXpXXXXX0kSEzt91nyadv" };

void setup() {

  char* auth = poss_auth[ROOM];
  char* ssid = my_ssid[LOCATION];
  char* pass = my_pass[LOCATION];

Thank you! Yes, that works. I swear I had tried this combination before but I must have not had all the pieces right at the same time! :slight_smile:

1 Like