Timing issue with button press

HOT DAM JML! You did it! That's what i needed. I'm going to go back thru you're code and study that. You're the man. I truly appreciate your help

Quick question, can you tell me how to serial print the name of the case (i.e. ALLoff, HOMERUN,). Right now it just shows 0,1,2... when it goes thru each case

Hold a char* array where their index matches the case number.

const char* showNames[] = { "ALL_OFF", "HIGHLIGHT", "PATRIOTIC", "BREATH",  "HOMERUN"};

also instead of this:

const byte ALLoff = 0;
const byte HIGHLIGHT = 1;
const byte PATRIOTIC = 2;
const byte BREATH = 3;
const byte HOMERUN = 4;

That's the perfect use for an enum like this:

enum Shows {
ALL_OFF = 0,
HIGHLIGHT,
PATRIOTIC,
BREATH,
HOMERUN
};
Shows showType = ALL_OFF; // Or whatever you want it to be. 

Then for the printing you'd just use Serial.println(showNames[showType]);

Note: Typed into the forum, so nothing has been tested.

st3v3n92:

Thanks! Ill give that a try

You might run into trouble trying to ++ an enum though, I believe you can do showType = showType + 1; or if that's a bit messy, you can write an operator overload for the ++;

const char* showNames[] = { "ALL_OFF", "HIGHLIGHT", "PATRIOTIC", "BREATH",  "HOMERUN"};
enum Shows {
ALL_OFF = 0,
HIGHLIGHT,
PATRIOTIC,
BREATH,
HOMERUN,
NUM_SHOWS
};
Shows showType = ALL_OFF; // Or whatever you want it to be. 

void setup() {
  Serial.begin(9600);
    for (; showType < NUM_SHOWS; showType = showType+1)
     Serial.println(showNames[showType]);
}

void loop() {}

This is tested now.

or you can add a simple dumb function :scream: :innocent:

void printShowName(int showNumber) {
  if (showNumber == ALLoff)         Serial.println(F("ALLoff"));
  else if (showNumber == HIGHLIGHT) Serial.println(F("HIGHLIGHT"));
  else if (showNumber == PATRIOTIC) Serial.println(F("PATRIOTIC"));
  else if (showNumber == BREATH)    Serial.println(F("BREATH"));
  else if (showNumber == HOMERUN)   Serial.println(F("HOMERUN"));
  else                              Serial.println(F("Unknown Show"));
}

void startShow(int i) {
  printShowName(i);   // print the name of the current show
  switch (i)  {
    case ALLoff:
      ....

Thanks JML

The dumb way worked for me! :sweat_smile:

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