D&D Table lighting

Sorry if I'm breaking any norms or decorum by just asking for help on a project. I'm sure this is ultra basic to the veterans out there, but hey, here we are. Putting on my full nerd hat. :nerd_face:

Setup:: I've got a strip of addressable LEDs (details below) I want to run around my D&D table. I've got them powered and am starting to run some code to address sections with an Uno, but I want to be able to control which sections are illuminated on the fly. So that's where I need the hive mind.

Goal 1: When we run combat in the game we have to roll initiative to determine the order in which the players go. I made a little subroutine to light up ~20 LEDs at a given location in the strand in a fancy pattern and I'd like it to light up in front of them on their turn. But the order changes every combat. I can predefine the locations that light up say A-B-C-D-E-F-G

I need to I quickly at the start of combat tell the Arduino which section to light up when I click a button for "next" or something similar.

Goal 2: Being able to light up 2 or 3 of those lettered sections simultaneously should the party get split as a visual marker for who is together. Then be able to toggle between those preset groupings.

Goal 3: General mood lighting to accent the scene. Ruddy red of a dragons' lair. Being able to adjust the entire strand for brightness and color as needed. As I type it some potentiometers seem like the logical choice. :woman_shrugging:But maybe some preset effects, washing shades of blue for underwater scenes, mixing transitions of red, yellow, orange for fire.

LED Details: WS285, on dedicated 12v power supply. 16 feet long, 300 LEDs.

EDIT: For clarity, looking for hardware suggestions more than coding suggestions. :sweat_smile:

It's hard to suggest changes/updates to Your code and the crystal ball is not available for the moment.

Oh. I'll edit for clarity. Not as worried about the coding, but the best way to do hardware inputs. Buttons, nobs, etc.

Investigate the various type of thumb wheel switches you can get. It will be an easy way to select what pattern you want to select. Then just a push button to choose when to switch to that pattern.

You might want an OLED or TFT display so that you can give those patterns names, so they are simpler to remember.

I would also include controls for speed and brightness.

I wrote code while my students took a test today. I haven't been able to test it as my setup is at home, but it verifies without any crazy errors.

Here's the code for setting then running initiative:

void Initiative () {
  char key=keypad.getKey();
  int order = 0;
  int battle[15]; //Initalize for 15 possible turns in a round of combat
  
  //Set Initiative Order ending when the key "0" is pressed
  while(key != "0"){
    ++order;
    key=keypad.getKey();
    if(key!="0"){
      battle[order]=9+(33*(atoi(key)-1));
    }
  } //End Setting Loop
  
  //Run Initiative
  int turn=0;
  while (key!="0"){
    key=keypad.getKey();
    if (key= "#"){
      ++turn;
      FadeIn (battle[turn]);
    }
    if (key="*"){
      --turn;
      FadeIn (battle[turn]);
    }
    if (turn==order){
      turn=0;
    }
  } // End Running Loop
} // End Initiative

Here's the code to fade in at their location each time:

void FadeIn (int Position){
  int Fade = 200;
  int FadeMod = 1;
  int j=Position+1;
  for (int k=0;k<=200;k++){   // Center Fade Loop
    leds[Position]=CRGB(0,0,k);
    leds[j]=CRGB(0,0,k);
    FastLED.show();
  }  //End Center Loop

  for (int i=Position;i<=Position+10;i++){    // Spread Out Loop
    j--;
    if (Fade==200){
      FadeMod=-1;
    }

  leds[i]=CRGB(0,0,Fade);
  leds[j]=CRGB(0,0,Fade);
  Fade+=(20*FadeMod);
  Serial.println(Fade);
  delay(75);
  FastLED.show();
  }
}

Put a button at each station and have the players ring in to see who wins the attack or somesuch. You can buy brightly color domed buttons like they use on arcade games. Those buttons, too, have lights.
You can just randomly select segments and measure the time between "GREEN" and their response. Randomly pick two players and the fastest reaction time wins.

Perhaps as a review game for my classroom students... but not for my dungeons and dragons crew... not quite applicable.

If keypad.getKey() returns a character, as the declaration and initialisation of key implies, then you are going to want to compare that character to a character, not a string.

  while(key != '0') {

and similarly in the other places you now have a string literal and not a character constant.

a7