Go Down

Topic: Setting stepper motor to just 1 revolution per day (Read 171 times) previous topic - next topic


Hello, I'm a total noob at this (programming and stepper motor stuff). So I've been trying get a 28BYJ-48 to complete one turn in 24 hours, but the best I can do, is to make it turn at 1 revolution per hour (by luck). The original code allowed me to get a 1 rpm

This is the code I am using, I found it somewhere in the internet, and I'm just changing de steps per revolutin setting and the setSpeed. The original code allowed me to get a 1 rpm, so the StepsPerRevolution line was in 2038 and the SetSpeed was in 60.

#include <Stepper.h>
const int stepsPerRevolution = 32;  // 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:
  // initialize the serial port:
void loop() {
  // step one revolution  in one direction:

Thanks in advance for your help!


86400 seconds per day
32 steps per revolution
86400 / 32 = one step every 2700 seconds.

Best not to use delay() though, if you plan on using the processor for anything else.

Please remember to use code tags when posting code.
"Pete, it's a fool (who) 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.


Just get the Stepper library to make one step at a time and ask for the step to be made at the appropriate interval to give the speed you want.

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


Checkout how BlinkWithoutDelay example works, use the same method.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]


2700 seconds is quite a long time, if you want really smooth motion you might be better off running the motor a bit faster then using some gearing to reduce the rotation rate of whatever it is that you are turning. Perhaps a system of gears or worm gear giving a 100:1 reduction ratio, so you can have the motor move a little bit every 27 seconds.


Sep 21, 2018, 03:07 am Last Edit: Sep 21, 2018, 03:10 am by outsider
The 28BYJ-48 has a 64:1 gear ratio so one revolution of the output shaft takes 2048 steps, for 1 rev per day it would take:
86400 seconds / 2048 steps = 42.1875 seconds per step. (42188 millis or 42187500 micros).

Go Up