@xd1936
sizeof returns the total size of the variable. Not the number of indices of an array.
But you can get the size of one field of an array.
if you divide the total size by the size of the first field, you end up with the number of indices.
get rid of the Arduino Strings. You get cleaner and shorter code.
const char *modeTxt[] = {"calendar", "weather"};
size_t mode = 0; // current mode
void setup()
{
Serial.begin(115200);
}
void loop() {
//Serial.println("Fetching " + String(modeTxt[mode]));
Serial.print(F("Fetching "));
Serial.println(modeTxt[mode]);
modeNext();
delay(500); // dirty delay to slow down
}
// increase mode, switch to next mode or wrap around on end
void modeNext()
{
mode++;
if (mode >= sizeof(modeTxt)/sizeof(modeTxt[0])) mode = 0;
}