Go Down

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

johannesr95

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.


AWOL

"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.

Robin2

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.

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

johannesr95

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:
 myStepper.setSpeed(70);
 // initialize the serial port:
 Serial.begin(9600);
}

void loop() {
 // step one revolution  in one direction:
 Serial.println("clockwise");
 myStepper.step(stepsPerRevolution);
 delay(500);

 // step one revolution in the other direction:
 Serial.println("counterclockwise");
 myStepper.step(-stepsPerRevolution);
 delay(500);
}

johannesr95

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

Robin2

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.

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

TomGeorge

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.

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

joeblogs

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