3-4 Months now.

I have been trying to make my drapes automatic.
I have tried 3 programs from Instructables that i could not get working.
Also got no replies from questions.

I have this one i’m working on but have struck trouble.

Arduino: 1.8.9 (Windows 7), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Disabled, 4M (no SPIFFS), v2 Lower Memory, Disabled, None, Only Sketch, 115200"

D:\$Tutorial Videos\Nige_Test\Nige_Test.ino: In function 'void loop()':

Nige_Test:40:7: error: 'request' was not declared in this scope

   if (request.indexOf("/Command=forward") != -1)  { //Move 50 steps forward

       ^

Nige_Test:42:16: error: 'i' was not declared in this scope

           for( i=1;i<=50;i++){

                ^

Nige_Test:47:5: error: 'value' was not declared in this scope

     value = HIGH;

     ^

Nige_Test:52:16: error: 'i' was not declared in this scope

           for( i=1;i<=50;i++){

                ^

Nige_Test:59:1: error: expected '}' at end of input

 }

 ^

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

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Here is full sketch…

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "YourAuthToken";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "YourNetworkName";
char pass[] = "YourPassword";

int Step = 0; //GPIO0---D3 of Nodemcu--Step of stepper motor driver
int Dir  = 2; //GPIO2---D4 of Nodemcu--Direction of stepper motor driver


void setup()
{
  // Debug console
  Serial.begin(9600);

  delay(10);
 pinMode(Step, OUTPUT); //Step pin as output
 pinMode(Dir,  OUTPUT); //Direcction pin as output
 digitalWrite(Step, LOW); // Currently no stepper motor movement
 digitalWrite(Dir, LOW);  


  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
}

void loop()
{
  Blynk.run();


  if (request.indexOf("/Command=forward") != -1)  { //Move 50 steps forward
    digitalWrite(Dir, HIGH); //Rotate stepper motor in clock wise direction
          for( i=1;i<=50;i++){
          digitalWrite(Step, HIGH);
          delay(10);
          digitalWrite(Step, LOW);
          delay(10);}
    value = HIGH;

  
  if (request.indexOf("/Command=backward") != -1)  { //Move 50 steps backwards
    digitalWrite(Dir, LOW); //Rotate stepper motor in anti clock wise direction
          for( i=1;i<=50;i++){
          digitalWrite(Step, HIGH);
          delay(10);
          digitalWrite(Step, LOW);
          delay(10);}
    value = LOW;
  }
}

You have tried to use variables and an object that you haven’t defined.

The variables should be simple to fix, but it is unclear to me what a “request” is, probably a String.

You also need to match braces - the IDE’s auto format tool should help with that.

The errors are very clear. Your sketch uses 2 variables that it does not declare as anything?

Is the i variable used in the for-loops a byte or an int? You must say. Is it global or local? You don’t say.

The variable value is also not declared but what the heck, you only set it and never use it for anything else.

My hunch is that this is not all your code.

Instructables doesn’t test anything. They just post, they don’t filter garbage out.

The error says it all. You’re trying to use objects which were never declared.

Nige9095:

Nige_Test:40:7: error: 'request' was not declared in this scope

if (request.indexOf("/Command=forward") != -1)  { //Move 50 steps forward

In the case of request, it seems you copy pasted some code from somewhere without fully understanding it. Go back to the original source of that code and start studying it line by line until you fully understand every line. If there is something you don’t understand, start with the Arduino Language Reference. You might find this section relevant to your specific problem:
https://www.arduino.cc/reference/en/language/variables/data-types/stringobject/
If you don’t find what you need there, head over to Google. If you still can’t find the information you need after researching it, you can come back her to the forum and ask specific questions and we’ll help you out. Once you think you fully understand that line, write a simple test sketch using the concept and upload it to your Arduino to verify it works as expected.

You might also study what the terms “declare”, “define” and “initialize” mean in C++ (the language your sketch code is compiled as). That understanding would make the meaning of the error messages more clear, as well as making it easy to understand why your code is not valid.

The key is to learn the fundamental concepts before you jump into a complex project. That may seem slow at first, but I guarantee you would have been way farther along with your project by now, and had a lot less frustration if you had taken that approach.

Nige9095:
Nige_Test:42:16: error: ‘i’ was not declared in this scope

for( i=1;i<=50;i++){

Here, things are pretty simple. I think if you spend a little time comparing your code to the examples in the for reference page you’ll see what the problem is:
https://www.arduino.cc/reference/en/language/structure/control-structure/for/

Nige9095:
I have tried 3 programs from Instructables that i could not get working.

You should be aware that a disturbingly high percentage of the Arduino projects on Instructables are of a very low quality. Don’t assume that the authors of the tutorials you find there knew what they were talking about, or even bothered to do the most minimal amount of testing.

Hello Nige9095,

Welcome to the forum,

I suspect from the simple nature of your mistakes that you have not tried the various examples provided for you in the Arduino IDE and elsewhere. Work though these, understand them and the language then the mistakes that have been pointed out to you should become obvious.

Most of all, have fun! :slight_smile:

Jumping into something complicated beyond your knowledge... I hope that your first goal is to learn and second is to make.
And once you have made one thing with knowing, the next is not so far.

Thank's for your quick replies.
In the morning i will try all the things you have pointed out but,
I feel at the moment this will end up being a bin project.

You quit because you might have to learn to program?

Have you maybe someone else to do that part, a smart teenager? Family, friends, community? A teacher?

There is another part of the forum where you can hire a job, get the code and build the hardware yourself.

And lastly — what you want has probably been done here more than once. The threads with the information can be searched for, the forum archives go back for years. A lot of people get answers here without asking a single question just by looking through the site and forum.

Nige9095:
I feel at the moment this will end up being a bin project.

Looks like it's curtains for the drapes

Instructables are great for inspiration: see how things may be done. Lots of great ideas there. Too many errors in code/schematics, too many omissions of essential bits, poorly tested/worked out, etc, to make be able to replicate most of the projects posted there.

In general it's easier to develop your own code rather than trying to reuse otehr people's code, unless that code is specifically designed for re-use (usually by turning it into a library, and adding documentation describing how it works, etc).