Difficulty building library

Hi there,

I’m trying to make a stepper motor work.

So I got the library from ENGYFUN, but I did not succeed to implement it.

I checked all syntax, but it will not compile, and the IDE keeps telling it does not know the two functions “dureePas” and “nbPas”. There is probably some syntax error somewhere, but in spite of searching, changing names… I 'm stuck!!

The library is in the good directory, and the instantiation of “motor” seems to work because “StepperMotor” is written brown, which proves that the lib is recognized!

Here are the codes:

Main program:

#include <StepperMotor.h>

StepperMotor motor(8,9,10,11);

void setup(){

void loop(){


#ifndef StepperMotor_h
#define StepperMotor_h

#include	"Arduino.h"

class StepperMotor
    StepperMotor(int In1, int In2, int In3, int In4);    // Constructor that will set the inputs
    void dureePas(int duration);    // Function used to set the step duration in ms
    void nbPas(int noOfSteps);    // Step a certain number of steps. + for one way and - for the other

    int duration;    // Step duration in ms
    int inputPins[4];    // The input pin numbers



#include <Arduino.h>
#include <StepperMotor.h>

StepperMotor::StepperMotor(int In1, int In2, int In3, int In4){
    // Record pin numbers in the inputPins array
    this->inputPins[0] = In1;
    this->inputPins[1] = In2;
    this->inputPins[2] = In3;
    this->inputPins[3] = In4;

    // Iterate through the inputPins array, setting each one to output mode
    for(int inputCount = 0; inputCount < 4; inputCount++){
        pinMode(this->inputPins[inputCount], OUTPUT);
    duration = 50;

void StepperMotor::dureePas(int duration)
    this->duration = duration;

void StepperMotor::nbPas(int noOfSteps)
        The following 2D array represents the sequence that must be
        used to acheive rotation. The rows correspond to each step, and
        the columns correspond to each input. L
    bool sequence[][4] = {{LOW, LOW, LOW, HIGH },
                          {LOW, LOW, HIGH, HIGH},
                          {LOW, LOW, HIGH, LOW },
                          {LOW, HIGH, HIGH, LOW},
                          {LOW, HIGH, LOW, LOW },
                          {HIGH, HIGH, LOW, LOW},
                          {HIGH, LOW, LOW, LOW },
                          {HIGH, LOW, LOW, HIGH}};
    int factor = abs(noOfSteps) / noOfSteps;    // If noOfSteps is +, factor = 1. If noOfSteps is -, factor = -1
    noOfSteps = abs(noOfSteps);    // If noOfSteps was in fact negative, make positive for future operations

        The following algorithm runs through the sequence the specified number
        of times
    for(int sequenceNum = 0;  sequenceNum <= noOfSteps/8; sequenceNum++)
        for(int position = 0; ( position < 8 ) && ( position < ( noOfSteps - sequenceNum*8 )); position++)
            for(int inputCount = 0; inputCount < 4; inputCount++)
                digitalWrite(this->inputPins[inputCount], sequence[(int)(3.5 - (3.5*factor) + (factor*position))][inputCount]);

And the text file:

StepperMotor	KEYWORD1
nbPas			KEYWORD2
dureePas		KEYWORD2

Thanks for any help.


It compiles without errors here...

Are you sure that: 1) You placed it in "[Documents]\Arduino\libraries\StepperMotor\" ([Documents] is your mu documents folder. Arduino is the default sketchbook folder.) 2) You named the files "StepperMotor.h" and "StepperMotor.cpp" (And not "StepperMotor.h.txt")

Yes to both questions. I did exactly as the "morse" library tutorial.

Thanks for looking.


Could you please post the exact error messages you get from the IDE?



Hera are the messages...

Stepper.ino: In function 'void setup()': Stepper.ino:7:9: error: 'class StepperMotor' has no member named 'dureePas' Stepper.ino: In function 'void loop()': Stepper.ino:11:9: error: 'class StepperMotor' has no member named 'nbPas' Stepper.ino:13:9: error: 'class StepperMotor' has no member named 'nbPas' 'class StepperMotor' has no member named 'dureePas'

Thanks. Gerard.


I solved the problem. This was due to bad directory.

Apparently ARDUINO (the IDE internal program) does not accept accented characters, and I unfortunately have some accented characters in my files. So the library was not in the good directory, as ARDUINO created his own directory with non accented letter (in the "preference" link).

I rearranged these, and now it's OK.

May be this could save some trouble to those who use weird characters.

Thanks to all for help.