Go Down

Topic: Stepper motor help (Read 325 times) previous topic - next topic


Hello !

I'm working on a home automation project where my curtains open and close, i'm using a stepper motor to control this action, i used the included stepper motor library to get the motor moving but now i need some help with the code to make it move either clockwise or counter-clockwise depending on a input.


"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.


What have you tried? Post your program code.

Post a link to the datasheet for your stepper motor.
And tell us what stepper motor driver you are using.

Stepper Motor Basics
Simple Stepper Code
Two or three hours spent thinking and reading documentation solves most programming problems.


Ooops Sorry really new to this forum, but here is the code.

Stepper Motor Control - one revolution

This program drives a unipolar or bipolar stepper motor.
The motor is attached to digital pins 8 - 11 of the Arduino.

The motor should revolve one revolution in one direction, then
one revolution in the other direction.

Created 11 Mar. 2007
Modified 30 Nov. 2009
by Tom Igoe


#include <Stepper.h>

const int stepsPerRevolution = 200;  // change this to fit the number of steps per revolution
// for your motor

// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);

void setup() {
 // set the speed at 60 rpm:
 // initialize the serial port:

void loop() {
 // step one revolution  in one direction:

 // step one revolution in the other direction:


This is the motor: http://www.velleman.eu/products/view/?country=be&lang=en&id=411638

This is the controlller: http://www.velleman.eu/products/view/?country=be&lang=en&id=435576


The program you posted in Reply #3 makes the motor move in both directions. So all you now need is some code to change the value of a variable from (say) 'F' to 'R' so that you can control the direction.

Two or three hours spent thinking and reading documentation solves most programming problems.


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.

Thanks.. Tom.. :)
Everything runs on smoke, let the smoke out, it stops running....


you need to code in an input.

limit switches at top or bottom, read if they are on or off with digital read.

you could count the steps or revolutions and work out how many you need to get to the top bottom

or both

start with learning how to use a "switch statement", and how to put pieces of code into "functions"

Go Up