No announcement yet.

Help with controlling a stepper motor form an interface, using arduino

  • Filter
  • Time
  • Show
Clear All
new posts

  • Help with controlling a stepper motor form an interface, using arduino

    Good morning,

    I am working on a project which consists on an orbital welding machine. I need stepper motors to control accurately the degrees that my pieces have to turn and also the rotation speed.
    For this purpose I am using arduino uno and the driver a4998 to control a nema 17 4V 1.2 amps/phase and 1.8°/step.
    I am pretty new using arduino, that is why my code is so simple...

    #include <Stepper.h>

    #define STEPS 200

    Stepper stepper(STEPS, 8, 9);

    void setup()


    void loop()



    Looking forward, my intention is to control the system from an interface, being able to chose the number of degrees and rotation speed from a LCD monitor, apart from other possible commands.

    I have just discovered your products and I have seen that some of them are adaptable to arduino. What I want is if you could tell me if there is a real possibility to achieve this, and if so, once I have purchased your monitor and shield, if I can get any help from you in order to program my interface and the connection to arduino.

    Thank you. Regards

  • #2
    Hi abelliom,

    If you mean that can the display write values to this functions "stepper.setSpeed(100)" and "stepper.step(200)", then yes it can set the motor speed and turnt he motor a specific number of steps. For example the 4D Display has a "Slider" object that has a min and maxvalue from 0-100. The arduino can read the value from the slider object and can write to "stepper.setSpeed(slider_val)".

    Since you are new to arduino and 4D display, you can read this application note:

    ViSi - Genie Connecting a 4D Display to an Arduino Host:

    "This Application Note explores the possibilities provided by the ViSi-Genie environment in Workshop to work with an Arduino host. In this example, the host is an AVR ATmega328 microcontroller-based Arduino Uno board. The host can also be an Arduino Mega 2560 or Due. Ideally, the application described in this document should work with any Arduino board with at least one UART serial port. "

    Also there are other application note, code example, and projects that can help you:

    Code Examples:

    This project: - is a simple ViSi Genie project that controls the position of a DC servo motor using an Arduino Uno and a Picaso display module.


    • #3
      Hello Simon,

      Thanks for your answer. Before starting to read tutorials and programming, which is gonna take me a lot of time... , a doubt comes to my mind... Watching the video of the servomotor you have posted we can see that it can modify its position in real time when you manipulate the knob on the screen. My case with the stepper motor is a little bit different. What I would like to do is to load the values of the speed and the position of the motor, using a slider and a knob on the screen for example, and then trigger somehow the arduino to make the motor turns with the configuration already loaded. It is for example what you can do from the ide of arduino, you modify the parameters and then you load the code to arduino. I hope I am explaining myself well, I don't want that my motor responds automatically when I modify the values from the screen.

      Would this be possible somehow?

      Thanks for your time


      • #4
        Hi abelliom,

        Yes it is possible. For example you have 2 sliders in the screen to give values to speed and step of the stepper motor. Also you have a button int the display to execute the values set from the sliders to the stepper motor. The arduino will constantly read the slider values and store it in a variable. Then if the button is pressed, the arduino will then write to "stepper.step(slider1_val)" and "stepper.setSpeed(slider2_val)". This example does not always write readings from slider or knob to the stepper, it will wait first if a button is pressed to execute making the sample not in real time.


        • #5
          Hi Symon,

          Could you give me a short example of how I could do this with my code?

          Thank you very much



          • #6
            Hi abelliom,

            Sorry we don't have a stepper motor here at the moment. But given the samples, application notes and the "suggested flow" of what you want to do. Then you can easily create your own project.