Hello, I have just written this code and I’m using a stepper motor along with leds and Putty but for some reason i keep getting this error message “Undefined Symbol SMotor:: step(int, int, int).” Any help of how I can fix the issue is appreciated. Thanks.
#include “mbed.h”
#include “MMA8452.h”
#include “stdio.h”
#include “sMotor.h”
// DigitalOutputs for LEDs
DigitalOut led1(p13);
DigitalOut led2(p14);
DigitalOut led3(p15);
DigitalOut led4(p16);
DigitalOut led5(p17);
DigitalOut led6(p18);
DigitalOut led7(p19);
DigitalOut led8(p20);
DigitalOut led9(p21);
DigitalOut led10(p22);
DigitalOut led11(p23);
DigitalOut led12(p24);
Serial pc(USBTX, USBRX);
double x, y, z;
MMA8452 acc(p28, p27, 100000);
int value;
sMotor motor(p9, p10, p11, p12);
int step_speed = 900;
int numstep = 360;
int main() {
while(1) {
numstep = (rand()%360);
acc.readXYZGravity(&x,&y,&z);
pc.printf("x:%1f y:%1f\r\n",x,y);
wait(0.25);
if (numstep >= 0 && numstep >= 0) {
led1 = 0;
led2 = 0;
led3 = 0;
led4 = 0;
led5 = 0;
led6 = 1;
led7 = 0;
led8 = 0;
led9 = 0;
led10 = 0;
led11 = 0;
led12 = 0;
pc.printf("%d Step forward\n\r", numstep);
motor.step(numstep,0,step_speed);
wait(0.25);
pc.printf("%d Step backwards\n\n\r", numstep);
motor.step(numstep,1,step_speed);
wait(0.25);
}
}
}