Passing char to a function

I am trying to figure out how to pass an variable from one function to another.
I currently has cases for each media file I have loaded. case:a,b,c,d......
So my function is playwav(char effect, int volume) so i can manually specify playwav('a', 3.0) and it plays that file.
Here is what i want to accomplish, i have 4 conditions in my project. I have a function checking every 30 seconds what condition is active (by true/false) Is there a way to pass the char based on what condition is currently running? I am setting up a timer to repeat a file every 15 minutes, but i want that file to match the condition that could change within that 15 minute window. I am lost here, any advice would be appreciated. Thank you

if (condition == 0)
{
  playwav('a',3.0);
}
else
if (condition == 1)
{
  playwav('b', 3.0);
}

or neater

  char * wavs[] = {'a', 'b'};
  playwav(wavs[condition], 3.0); //assuming condition will have a value of 0 or 1

ok so it is that simple. I was doing something like that before but didn't think it would work.....what im trying to do is if condition 1 = true, pass that along to a timer function like timer(1000, function) where function would be the variables (a,b,c...) if that makes sense.

did you mean const char instead of char* ?

my current function is playwav((case, volume). I want to pass these to timer function. timer function is play(1000, *) i want * to be a b c ect... or is what you posted what i need?

Yes

I am currently trying to do research on this, im just not understanding the examples as none of them align with what im trying to do. Could someone give me an example?

Let's suppose that you have a function named play() that takes an int and a char

You could call it like this

play(1000, 'A');

or you could call it like this

char trackName = 'A';
play(1000, trackName);

Where are you stuck ?

I'm stuck where it how to pass the char. The original function is in loop with if and else statements the code looks for the condition that is true and passes the letter to the play wav. I'm just not sure how to take that to the timer functio

Sorry not pass each if statement has the full playwave command in itn

Hello,
post a handdrawn picture that presents the wanted conrol and dataflow.

What is so different about calling the timer() function rather than the play() function ?

the variables aren't global, at least i dont think so, the timer is in a void above the loop as the timer code cant loop or it resets....with them not being global can i still call them?

post the code...

my crystal ball is in the dish washer :nerd_face:

void alarm_high1(){

if (alarm_high){

(currentTime - previousTime >= Alarm_high){(playWAV('b', 3.0));

previousTime = currentTime; }

}

}

void alarm_low1(){

if (alarm_low){

(currentTime - previousTime >= Alarm_low){(playWAV('c', 3.0));

previousTime = currentTime; }

}

}

void error1(){

if (error){

(currentTime - previousTime >= Error){(playWAV('e', 3.0));

previousTime = currentTime; }}}

void no_readings1(){

if (no_readings){

(currentTime - previousTime >= No_readings){(playWAV('g', 3.0));

previousTime = currentTime; }

}

}

void normal_range1(){

if (normal_range){

(currentTime - previousTime >= Normal_range){(playWAV('h', 3.0));

previousTime = currentTime; }

}

}
Sync){(playWAV('n', 3.0));

Ignore the millis code, i was trying to use millis and it didn't work, havn't deleted that code yet.

I had if else statements but i redid the code for millis and just havn;t put it back yet

Please post a complete sketch rather than just part of one and use code tags when you do

See How to get the best out of this forum

My ino file is over 2000 lines are you sure you want the whole thing?

make a smaller code demonstrating what you are trying to do. The code you posted above (please fix it with code tags) makes no sense at all

what do you expect from this?

  if (alarm_high) {
    (currentTime - previousTime >= Alarm_high) {  // ????? missing an if ?
      (playWAV('b', 3.0));
      previousTime = currentTime;
    }
  }

Either that or a small but complete sketch that illustrates the problem. Auto format it in the IDE, right click and select Copy for forum, post it here and the code tags will have been added automatically