Controlling the speed of a 28BYJ-48 stepper motor

Hello, i was wondering how can i use a program to control the speed of a 28BYJ-48 stepper motor with the ULN 2003 board. I want to be able to switch speeds without using a potentiometer or any other hardware other than the arduino. I was not able to find anything on how to do this. I want to have 3 preset speeds (one is stop) and be able to jump between them by pressing a button etc. I have my motor set up like the picture and i use 9v batteries to power the motor. I know that it works because i uploaded some examples from the library and it worked.

Not wired like that it won't work, no ground.

Motor speed is set in software. Just take the knob control example and just use a variable assignment in place of reading the pot.

@tefras14,
Did you use this example tutorial ?
http://www.electrodragon.com/w/index.php?title=ULN2003_board

Grumpy_Mike:
Not wired like that it won’t work, no ground.

Motor speed is set in software. Just take the knob control example and just use a variable assignment in place of reading the pot.

I have ground in the picture i show how i wired the stepper. I power it with 9V batteries and have the ground connected to the arduino ground since i have nothing else connected

raschemmel:
@tefras14,
Did you use this example tutorial ?
http://www.electrodragon.com/w/index.php?title=ULN2003_board

I used this example most because i want a constant speed until i accelerate or decelerate.

#include <AccelStepper.h>

AccelStepper stepper; // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5

void setup()
{  
   stepper.setMaxSpeed(1000);
   stepper.setSpeed(50);	
}

void loop()
{  
   stepper.runSpeed();
}

Why aren't you using a speed variable like Mike suggested ?

Its OK guys i figured it out. Thanks for the replies :slight_smile:

If you're not too busy could you post your solution for others who my find themselves in your situation ?

(it is customary to do that on the forum by the way)