Hello guys and first sorry for my english .
I have a plan for astrotracker , i know the gear ratio reducer that i need.
I'm using arduino uno from ebay and stepper motor 28BYJ-48 DC 5v with ULN2003 driver, as power supply im using power bank.
So , the hardest for me is the code, i want to program the stepper to do for unlimited time 0,7Rpm (252degrees) or 7rpm (2520deg) , one from the both, because the gear ratio will be 1000:1 or 10 000:1 (0,25deg per minute of the output shaft).
Any suggestions? I will be really thankful if someone do the code for me .
Thanks.
so the stepper library shows some examples
you could start from that one it's not that hard, just need time management
something like this could possibly work - just typed it in here, so no guarantee!
#include <Stepper.h>
// change this to fit the number of steps per revolution for your motor
const int stepsPerRevolution = 200;
// initialize the stepper library on pins 8 through 11:
Stepper astrotrackerStepper(stepsPerRevolution, 8, 9, 10, 11);
double rpm = 7.0;
unsigned long stepTime = 0ul;
void setup() {
}
void loop() {
 if (micros() >= stepTime) {
  astrotrackerStepper.step(1); // execute one step
  stepTime += (unsigned long) (((double) 60000000ul) / (rpm * (double) stepsPerRevolution));
 }
 // here you can do somehting else for a little while
}
microsecond precision might be overkill you can change that with millis()
instead of micros()
and 60000ul
instead of 60000000ul
Thanks, that worked but seems like the torque is very low. Is it possible to be in higher torque mode ( i dont know if its correct, only guessing) for example 2x higher revolutions but with pause so the final revolutions per minute will be again 7 .
the 28BYJ-48 5V is rated pretty low in terms of torque
I know but i think for this purpose is enough (It worked on the old model , now im making my own which is more compact and lightweight ) so i tried this code and gave me good torque, can you help me with the delay option, the rpms are way more than 10 Thanks and sorry for my stupid questions and asks.
int Pin0 = 10;
int Pin1 = 11;
int Pin2 = 12;
int Pin3 = 13;
int _step = 0;
boolean dir = true;// gre
void setup()
{
pinMode(Pin0, OUTPUT);Â
pinMode(Pin1, OUTPUT);Â
pinMode(Pin2, OUTPUT);Â
pinMode(Pin3, OUTPUT);Â
}
void loop()
{
switch(_step){
 case 0:
  digitalWrite(Pin0, LOW);Â
  digitalWrite(Pin1, LOW);
  digitalWrite(Pin2, LOW);
  digitalWrite(Pin3, HIGH);
 break;Â
 case 1:
  digitalWrite(Pin0, LOW);Â
  digitalWrite(Pin1, LOW);
  digitalWrite(Pin2, HIGH);
  digitalWrite(Pin3, HIGH);
 break;Â
 case 2:
  digitalWrite(Pin0, LOW);Â
  digitalWrite(Pin1, LOW);
  digitalWrite(Pin2, HIGH);
  digitalWrite(Pin3, LOW);
 break;Â
 case 3:
  digitalWrite(Pin0, LOW);Â
  digitalWrite(Pin1, HIGH);
  digitalWrite(Pin2, HIGH);
  digitalWrite(Pin3, LOW);
 break;Â
 case 4:
  digitalWrite(Pin0, LOW);Â
  digitalWrite(Pin1, HIGH);
  digitalWrite(Pin2, LOW);
  digitalWrite(Pin3, LOW);
 break;Â
 case 5:
  digitalWrite(Pin0, HIGH);Â
  digitalWrite(Pin1, HIGH);
  digitalWrite(Pin2, LOW);
  digitalWrite(Pin3, LOW);
 break;Â
  case 6:
  digitalWrite(Pin0, HIGH);Â
  digitalWrite(Pin1, LOW);
  digitalWrite(Pin2, LOW);
  digitalWrite(Pin3, LOW);
 break;Â
 case 7:
  digitalWrite(Pin0, HIGH);Â
  digitalWrite(Pin1, LOW);
  digitalWrite(Pin2, LOW);
  digitalWrite(Pin3, HIGH);
 break;Â
 default:
  digitalWrite(Pin0, LOW);Â
  digitalWrite(Pin1, LOW);
  digitalWrite(Pin2, LOW);
  digitalWrite(Pin3, LOW);
 break;Â
}
if(dir){
 _step++;
}else{
 _step--;
}
if(_step>7){
 _step=0;
}
if(_step<0){
 _step=7;
}
delay(1);
}
OK so that is a direct drive of a ULN2003 stepper motor driver board without using a library
well you have at the end of the loop delay(1);
so that code will pause 1ms there. as 1 ms is the minimum value and you don't want that, you could replace that by delayMicroseconds() and calculate how many microseconds are necessary to hit your desired RPM (as first approximation you can ignore the time it takes to execute the switch/case then you could measure in microsecond how long it really takes and fine tunes to hit your rpm more precisely)
I'm not sure that will give you more torque though. What's the max current provided by your bank?
PS/
you can simplyify a bit the code by removing the part for spinning in reverse
if(dir){
 _step++;
}else{
 _step--;
}
if(_step>7){
 _step=0;
}
if(_step<0){
 _step=7;
}
becomes
_step++;
if(_step>7) _step=0;
and remove the dir
variable that is now unused