Control Stepper Forward and Reverse with inductive Proximity limit switch

Hi Everyone,

I’m working on a kinetic sculpture for a swiftly approaching exhibition and I’m worried I won’t be able to figure out all my problems before my deadline (Second week of November). So I’m looking to pay someone to help me troubleshoot my existing hardware and code. I’d like to work with what I have already if it’s possible.

So my goal is to make a scissor lift on a linear stage with a sensor on each end that tells the motor to reverse/move forward in an endless loop. I am aware that this is a fairly common project but I’m still having trouble figuring it out on my own and I no longer have the time. So if you would be willing to take the job, I would greatly appreciate it!

Hardware list:
-Arduino Uno
-Nema 23 Stepper Motor 2.8A
-TB6560 3A Single 1 Axis Controller Stepper Motor Driver Board
-PC817 4-Channel Optocoupler Isolation Board 3.6-30V Driver
-M12 Sensor Inductive Proximity Switch NPN NC DC 6-36V

(I’ve attached photos of the hardware)

I started off by picking my hardware based on these tutorials:

Control stepper forward and reverse: Control Stepper Forward and Reverse with Proximity limit switch Arduino Tutorial - YouTube
Optocoupler Board: PC817 Adapter Module Optocoupler with Arduino - - YouTube
Driver board: Controlling a Stepper Nema17 with a TB6560 and Arduino - YouTube
Sensors: Using Inductive Proximity sensors with Arduino - YouTube

I used the following code from the first tutorial:

// defines pins numbers
const int stepPin = 5;
const int dirPin = 2;
const int enPin = 8;
const int LimitSwitch_LEFT_Pin  = 10;
const int LimitSwitch_RIGHT_Pin = 11;

void setup() {


  pinMode(LimitSwitch_LEFT_Pin , INPUT);
  pinMode(LimitSwitch_RIGHT_Pin , INPUT);

  // Sets the two pins as Outputs


  // Set Dir to Home switch
  digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction

void loop() {

    int leftSw  = digitalRead( LimitSwitch_LEFT_Pin);
    int rightSw = digitalRead( LimitSwitch_RIGHT_Pin);
    if( (leftSw  == HIGH && (digitalRead(dirPin) == HIGH)) ||
        (rightSw == HIGH && (digitalRead(dirPin) == LOW)) ){

    else if( leftSw == LOW && (digitalRead(dirPin) == HIGH) ){
    else if( rightSw == LOW && (digitalRead(dirPin) == LOW ) ){
void motorStep( int MAX){

   for(int x = 0; x < MAX; x++) {

I realize now that I probably picked the most difficult way to do this simple task but I’d like to compensate anyone that is willing to help me get the hardware and code working together to make the scissor lift go up and down. As of tonight, the sensors are responsive but the motor does nothing.

Thanks in advance!

Two questions:

  1. What do you want the thing to do?
  2. What's the budget?

I would like the scissor lift to be able to lift a small amount of weight. It will be pushing up and down some taut fabric to give it the appearance of breathing.

I’m not sure about budget. I guess I would negotiate the price depending on how much work it takes to get this mess working.

As of tonight, the sensors are responsive but the motor does nothing.

That's good. You should be able to get the motor moving.

The quick things to check.

First slow the step rate way down. Try delays of 500 milliseconds instead of microseconds.

Second, how is the enable wired, and does it want to be HIGH instead of LOW?

How are the dip switches set, and what is the current limit settings.

If you connect every input and every output to a LED in series with a resistor, you will quickly know what is going on. You can test the potential problems in cattledog's list.