Hi,
Coming from a JS background, I’m pretty new to C++ . Can’t seems to find out what’s wrong with this sketch, compile with no errors, however LED shows blinking red and restarted itself, and when it starts, it went red and repeat itself.
I’ve simplify to code, nevertheless I’m trying to store values (string) in an array and eventually, have a result outputs all data in the array. and since I can only output as string, i need to loop through the array and format them into a string. How can I do that?
int mockSAA = 233;
int mockSAB = 301;
char* message[128];
String result;
char resultChar[128];
void setup() {
for (int i = 0; i < 8; i++) {
message[i] = "null";
}
sprintf(message[6], "%c", mockSAA);
sprintf(message[5], "%c", mockSAB);
char ss[32];
for (int i = 0; i < 8; i++) {
sprintf(ss, "%d:%c, ", i, message[i]);
result.concat(ss);
}
result.toCharArray(resultChar, 65); //max length
Spark.variable("message", resultChar, STRING);
}
void loop() {
}
Cheers,
Edwin