Assigning a returned value to a variable errors

I am trying to delay the loop function until a value is inputted, and at the same time, know what value was input. The below code partially works, with the waitInput(); delaying the function until a button is pressed, but I am having trouble assigning the returned value to a variable.

Basically, if I change "waitInput();" to "char value = waitInput();" an error pops up saying: "void value not ignored as it ought to be"

void loop(){

void waitInput(){
  while (!Ev && !Tv && !Av && !Ov && !Iv && !Nv && !Sv && !Rv){
    Ev = digitalRead(E);
    Tv = digitalRead(T);
    Av = digitalRead(A);
    Ov = digitalRead(O);
    Iv = digitalRead(I);
    Nv = digitalRead(N);
    Sv = digitalRead(S);
    Rv = digitalRead(R);
  if(Ev){return "E";}
  else if(Tv){return "T";}
  else if(Av){return "A";}
  else if(Ov){return "O";}
  else if(Iv){return "I";}
  else if(Nv){return "N";}
  else if(Sv){return "S";}
  else if(Rv){return "R";}

So, how do I assign the returned value and where am I making the mistake at? Thank you.


void waitInput(){

The "void" in the function definition means that the return type of the waitInput() function is void, which means it doesn't return anything. This is why you're getting the error. If you want the function to return something then you first need to set the correct return type. It looks like you want it to return a char, so the function signature should look like this:

char waitInput(){

You should also be aware that "E" is a string, equivalent to this array of chars: {'E', 0}. That's not what you want. 'E' is the character E. So you need to use the correct type of quotes in your code.

That fixed my issue, thanks. The reason I asked with "char" was assigning it to a String value would throw another error, which looked more irrelevant to me.

"conversion from 'void' to non-scalar type 'String' requested"

No reason to use String. char is the appropriate type for this particular application.