Hello,
I created a class to manage commands thru serial port and i am using a stepper motor but when i am trying to use step function is not working.
I declare an object in arduino file and i used pointer of stepper object to wotk inside class. testing it, setSpeed method works fine but when i try to use step method, i got segmentation fault on compiling action.
main file
#include "ClassTest.h"
ClassTest test;
Stepper myStepper1 = Stepper(200, 8, 9, 10, 11);
void setup() {
test.SetupMotor(&myStepper1);
}
ClassTest.h
#include "Arduino.h"
#include "Stepper.h"
class ClassTest
{
public:
ClassTest();
void SetupMotor(Stepper* step);
void MoveMotor(String ,int );
private:
Stepper* _myStepper1;
};
ClassTest.cpp
void ClassTest::SetupMotor(Stepper* step)
{
_myStepper1=step;
_myStepper1->setSpeed(200);
}
void ClassTest::MoveMotor(String motor,int stepCount)
{
// i am getting an issue on compiling time about segmentation fault
_myStepper1->step(200);
}
I tried many things but not sure why is not working yet, any help???
Thanks!!