Declaring something in a scope

Hey guys i'm new to all of the coding stuff and i'm currently working on a project but i have hit a speed bump! i'm having trouble with compiling m code, and it appears that there is only one thing wrong with it and it is this error (

exit status 1
'stepper' was not declared in this scope

)
when i use what ever as variable except for void before 'stepper' the error is gone but not sure which one is correct so if you could help me to handle this i will appreciate it

here's the code:

void moveBox(bool inductiveState) {
if ( inductiveState == 0 ){
stepper.moveTo(steps); // random position to end for testing
stepper.runToPosition();
delay(1000);
stepper.moveTo(0);
stepper.runToPosition();
delay(1000);
}
else if (inductiveState == 1) {
stepper.moveTo(-steps); // random position to end for testing
stepper.runToPosition();
delay(1000);
stepper.moveTo(0); // random position to end for testing
stepper.runToPosition();
delay(1000);
}
}

Do those need a capital S?
What do the examples use?

here's the code:

We need to see the whole sketch

Where exactly is the stepper object created ?

In the fragment of code you have posted stepper is not declared at all. So based just on that the compiler is absolutely right.

There should be other mentions of stepper somewhere in your sketch which is why we need to see the COMPLETE sketch.

Steve

Read how to use the forum post at top of every page and put your code in code tags so others can help more easily. Then post all your code.

Hey guys! I've finally reached the end of my project but in saying that I've hit another speed bump. I've been trying and trying but I just cant seem to be able to compile my work! it would be great if you could help me! I sorta don't know what to put so yeah. thanks! :slight_smile:

There is no way that we can help without seeing the code and the error(s).

Read the how to use this forum-please read sticky to see how to properly post code. Remove useless white space and format the code with the IDE autoformat tool (crtl-t or Tools, Auto Format) before posting code. If the code is too large to post it can be attached. Better yet, make a minimal verifiable program that shows the problem.

Please include the entire error message. It is easy to do. There is a button (lower right of the IDE window) called "copy error message". Copy the error and paste into a post in code tags. Paraphrasing the error message leaves out important information.

I've finally reached the end of my project

but I just cant seem to be able to compile my work

So it is not actually complete after all

Follow the advice given in reply #1

Also here

I've merged your cross-posts @maribelle123.

Cross-posting is against the rules of the forum. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend 15 minutes (or more) writing a detailed answer on this topic, without knowing that someone else already did the same in the other topic.

Repeated cross-posting will result in a suspension from the forum.

In the future, please take some time to pick the forum board that best suits the topic of your question and then only post once to that forum board. This is basic forum etiquette, as explained in the sticky "How to use this forum - please read." post you will find at the top of every forum board. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.