Stepper codIng problem

Hello and thanks for reading…
I am trying to develop a code to run two steppers with feedback from limit 4 switches and a user toggle. I have modified some code below but I cannot get it to verify. It comes back with ‘invalid use of non-static member function’.
ERROR MESSAGE:
Arduino: 1.6.13 (Mac OS X), Board: “Arduino/Genuino Uno”

/Users/jamesdavis/Documents/Arduino/MultiStepper_1.2.17/MultiStepper_1.2.17.ino: In function ‘void loop()’:
MultiStepper_1.2.17:48: error: invalid use of non-static member function
{stepper1.run;} //FIND A WAY TO RUN STEPPER ACW
^
MultiStepper_1.2.17:50: error: invalid use of non-static member function
{stepper2.run;} //FIND A WAY TO RUN STEPPER ACW
^
MultiStepper_1.2.17:53: error: invalid use of non-static member function
if (OL==HIGH){stepper1.run;}
^
MultiStepper_1.2.17:54: error: invalid use of non-static member function
if (UT==HIGH){stepper2.run;}
^
exit status 1
invalid use of non-static member function

This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.

CODE:

// Desk riser and lid slider
// I am wanting to control two steppers to firstly slide back a bench top cavity lid and secondly lift a desk riser up.

#include <AccelStepper.h>
#include <MultiStepper.h>

AccelStepper stepper1(AccelStepper::FULL4WIRE, 2, 3, 4, 5);
AccelStepper stepper2(AccelStepper::FULL4WIRE, 6, 7, 8, 9);

// Up to 10 steppers can be handled as a group by MultiStepper
MultiStepper steppers;

int userPin = A0; //names userPin as the user switch and assigns it to analog pin 0
int DT = A1; //names DT as the Down Table switch and assigns it to analog pin 1
int CL = A2; //names CL as the Close Lid switch and assigns it to analog pin 2
int OL = A3; //names OL as the Open Lid switch and assigns it to analog pin 3
int UT = A4; //names UT as the Up Table switch and assigns it to analog pin 4

void setup() {
Serial.begin(9600);

// Configure each stepper
stepper1.setMaxSpeed(100);
stepper2.setMaxSpeed(100);

// Then give them to MultiStepper to manage
steppers.addStepper(stepper1);
steppers.addStepper(stepper2);
pinMode(userPin,INPUT);
pinMode(DT,INPUT);
pinMode(CL,INPUT);
pinMode(OL,INPUT);
pinMode(UT,INPUT);
}

void loop()
{
if (DT==HIGH);
{stepper1.run;} //FIND A WAY TO RUN STEPPER ACW
if (CL==HIGH);
{stepper2.run;} //FIND A WAY TO RUN STEPPER ACW
if (A0==HIGH);
{
if (OL==HIGH){stepper1.run;}
if (UT==HIGH){stepper2.run;}
}
}

Hi,
Welcome to the Forum

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html
then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Also look at how you write an IF statement, check your ; you have some where they don't go.

Tom.... :slight_smile:

if (DT==HIGH);

Remember that an if statement will run the next statement or statement block. When you put a semicolon that counts as an empty statement. So this translates to if (this) then do nothing. And the next block you have will be run unconditionally.

If statements shouldn't ever have semicolons.

{stepper1.run;} //FIND A WAY TO RUN STEPPER ACW

Isn't run a function? Shouldn't it have some parenthesis on it?