Value not returning a value

I set a variable equal to a string of commands however the variable isn't returning a value, perhaps something is wrong in the return statement below where I declared the variable?


here's the error message
image
I can display further details of the error messages if needed.

Please do not post pictures of code. Post all the code, using code tags.

I set a variable equal to a string of commands

Why would you do that? It is not valid C/C++.

Give every statement its own line. Then the code is easier to maintain.
Don't try to over-think or over-smart yourself.

Very creative. You are not allowed to be so creative yet. You can't just make stuff up.

If you want to be able to refer to a "string of commands" you should look into and learn about functions.

As for returning anything, to whom do you think the variables were being returned, and what were they supposed to do with them? Again it looks like you have something in mind, but improvisation does not enter into writing code, certainly def not your code at this point in your learning curves.

a7

What do you mean by "make stuff up"? I declared a value for the variable in the void setup, also while I will admit I am a beginner I do know the basic behaviors of functions, but not the extensive ones. Also, I might use an if/else statement to set a string of commands to a certain property of the variable, rather than what I currently have. As from previous comments, problems arise with the validity of that declaration. Also, I was going to return the variable when activating the string of commands however I never got to that point yet, I just returned it because, from my research, my error only occurs when the value wasn't returned and I wanted to see if the error would still occur. In the final product of the script, I would add more extensive instructions detailing what to do with the variable once it's returned.

Please post code using code tags which compiles, or fails with an error, and demonstrates your problem.

where you got this strange syntax code?

Is it a project with Morse code ?

This is with functions:

void setup()
{
  Line();
  Dot();
}

void Line()
{
  digitalWrite(A4, HIGH);
  delay(2000);
  digitalWrite(A4, LOW);
}

void Dot()
{
  digitalWrite(A4, HIGH);
  delay(500);
  digitalWrite(A4, LOW);
}

Your code is simply not valid c++
It seems you try to declare a function within a function.
That is not allowed.

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