Gesture Controlled Contactless Elevator With Stepper Motor

Hi,
I am pretty new to coding and especially Arduino. I am currently working on this model elevator that would be contactless helping to prevent the spread of Covid-19. I am Using an APDS-9660, a 128x64 OLED i2c display, and the ULN2003 Stepper Motor Driver Board with the Stepper Motor, both from the Rex Qualis Arduino Uno starter kit. I can have the sensor and the OLED work properly except when I tried to add the code for the motor and wire it up, the motor doesn't work. I have added serial.prints where the motor is supposed to run and they work so I am just confused why the motor won't work

I have attached my code as it was too large to add to the post and a picture of my circuit, I hope it is clear enough, as I do not yet know how to make a proper circuit diagram.

Thank you for your assistance in advance!

Gesture_Controlled_Elevator_with_Stepper_Motor.ino (16 KB)

change the line that says

Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);

to

Stepper myStepper(stepsPerRevolution, 8, 10, 9, 11);

see, pins 9 and 10 are swapped

.. and make sure you have all Grounds connected as common

I have no idea how the suggestion in Reply #1 was arrived at.

It seems to me the problem is that you are trying to operate the stepper motor on some of the SPI pins. Pins 11, 12 and 13 are used by SPI (and SPI cannot use any other pins) and usually also pin 10 for slave-select.

Try connecting the ULN2003 to some other I/O pins. Be aware that the analog pins will also work as digital pins.

...R

A stepper motor is no solution for an elevator, better use a geared DC motor. With a stepper motor you risk the platform falling into the cellar when loaded, with no chance to recover.

ULN200x are very poor motor drivers with high loss of voltage and energy. For a DC motor use a modern H-bridge, not the old L293D with twice the problem of the ULN darlingtons.

Doesn't the Starter Kit recommend a higher voltage for the stepper motor?

I'd suggest to fix the motor related part first, with ordinary buttons and small code that you can present to the forum. Once this version works it should not be hard to replace the buttons.

It doesn’t look like you have a common 0v line between the power supply and Arduino

Hi,
Welcome to the forum.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Please not a fritzy diagram.

Thanks.. Tom.. :slight_smile:

Hi,
Please do not update old posts, it is better and easier to follow the thread to just add new info in new posts.

That is a Fritzy, but we need a properly labelled schematic rather than a component layout picture.

You need to connect the gnd of the UNO to the gnd of the stepper control module.

Rather than ADDING to your code, write code for each part, get them working individually, then begin to combine them.
In this case you need to produce some code JUST to control the stepper to prove your code and hardware.

Tom... :slight_smile:

Sorry for updating the old post, my mistake.

I have a separate code for the elevator and for the OLED and APDS-9960 sensor that works properly in detecting the gestures and changing the floor numbers.

code for motor separately

//Includes the Arduino Stepper Library
#include <Stepper.h>

// Defines the number of steps per rotation
const int stepsPerRevolution = 500;
int i = 1;
int x = 1;


// Creates an instance of stepper class
// Pins entered in sequence IN1-IN3-IN2-IN4 for proper step sequence
Stepper myStepper = Stepper(stepsPerRevolution, 8, 10, 9, 11);

void setup() {
  // Nothing to do (Stepper Library sets pins as outputs)
}

void loop() {

  
  // Rotate CCW quickly
  if (x == 1){
    while (i < 46){
        myStepper.setSpeed(70);
        myStepper.step(-stepsPerRevolution);
        delay(1000);
        i = i +1;
        }
  }
}

code for elevator:
https://create.arduino.cc/editor/wagner8/bb731f8b-26f2-43fe-9b34-5fc412abf458/preview

This issue I am running into is when I attempt to combine the two. I am struggling to find the issue and to fix it.

thank you for your suggestions.

wagner8:
This issue I am running into is when I attempt to combine the two. I am struggling to find the issue and to fix it.

Have you considered what I wrote in Reply #2 ?

...R

You wrote or pasted ugly blocking code that does not work with other code. See BlinkWithoutDelay for non-blocking code in regular intervals. As soon as you successfully replaced delay() and the "while" loop you can start adding your other code.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.