Step Motor Program Error

Hello all, so I have a fairly simple issue. I tried to run this program on a fresh out of the box Arduino but it gave me an error message saying it couldn’t find the necessary directory folder.

Here is the program in question

#include <Stepper.h>

// Number of steps per revolution of INTERNAL motor in 4-step mode
#define STEPS_PER_MOTOR_REVOLUTION 48

// Number of steps per revolution of OUTPUT SHAFT (= gear reduction; 2048 steps)
#define STEPS_PER_OUTPUT_REVOLUTION 48 * 64

// Declare 'small_stepper' variable
Stepper small_stepper(STEPS_PER_MOTOR_REVOLUTION, 8, 10, 9, 11);

// Declare 'Steps2Take' variable
int  Steps2Take;
int joyX = A0;
int joyVal;
void setup()
{
  // Nothing  (Stepper Library sets pins as outputs)
  Serial.begin(9600);
}

void loop()
{
  joyVal = analogRead(joyX);
  Serial.println( joyVal);

  Serial.println();
  Serial.println("2");
  if ( (joyVal == 0) || (joyVal > 1000) ) {
    Steps2Take  = -48;// -STEPS_PER_OUTPUT_REVOLUTION / 2;  // Rotate CW 1/2 turn
    if ( joyVal > 1000) Steps2Take = Steps2Take * -1;
    small_stepper.setSpeed(500);
    small_stepper.step(Steps2Take);
    delay(10);
  }


}

As far as I can tell, I am getting the error message because I do not have the Stepper.h library I need, but I cannot seem to find it.
I tried using this library but it doesn’t seem to work

Any recommendations?

Stepper.h is in my IDE files.

Paul

Thank you! I am no longer getting the directory error, now I am getting an upload error. I tried burning the bootloader but even that wouldn't work. I have the programmer set to Arduino as ISP as that is the only one that doesn't immediately error. What can I do?

Please do this:

  • File > Preferences > Show verbose output during: > compilation (uncheck) > upload (check) > OK
  • Sketch > Upload
  • After the upload fails you’ll see a button on the right side of the orange bar “Copy error messages”. Click that button.
  • Paste the error messages in a reply here USING CODE TAGS (</> button on the forum toolbar).

Arduino: 1.8.12 (Windows 10), Плата:"Arduino Uno"

C:\Users\Artur\Documents\Arduino\stepper\stepper_speedControl.ino: In function 'void setup()':

stepper_speedControl:14:6: error: redefinition of 'void setup()'

void setup()

^~~~~

C:\Users\Artur\Documents\Arduino\stepper\stepper.ino:1:6: note: 'void setup()' previously defined here

void setup() {

^~~~~

C:\Users\Artur\Documents\Arduino\stepper\stepper_speedControl.ino: In function 'void loop()':

stepper_speedControl:20:6: error: redefinition of 'void loop()'

void loop()

^~~~

C:\Users\Artur\Documents\Arduino\stepper\stepper.ino:6:6: note: 'void loop()' previously defined here

void loop() {

^~~~

exit status 1 redefinition of 'void setup()'

Этот отчёт будет иметь больше информации с включенной опцией Файл -> Настройки -> "Показать подробный вывод во время компиляции"

You are only allowed one setup() and one loop() function in your sketch. You have one of each in the sketch file stepper.ino and one of each in the sketch file stepper_speedControl.ino.

The Arduino IDE allows you to add multiple .ino files to your sketch. These are shown as different tabs in the Arduino IDE. At the start of the compilation process, all the .ino files of the sketch are concatenated, starting with .ino file that matches the folder name (stepper.ino) followed by the rest in alphabetical order. So the .ino files become a single file. Breaking your project into logical parts in separate .ino files simply makes it easier to navigate the code by clicking the tab of the section of code you want, rather than scrolling through a zillion lines of code in a single file.

If stepper.ino and stepper_speedControl.ino are actually individual programs that you happened to put in the same C:\Users\Artur\Documents\Arduino\stepper folder, then you only need to move stepper_speedControl.ino to its own dedicated folder. If they are parts of a single program, then you will need to merge the code to avoid these redefinition errors. There are many excellent tutorials about merging Arduino sketches that can be found with a quick Google search.