Pages: [1]   Go Down
Author Topic: Controlling the speed of a 28BYJ-48 stepper motor  (Read 172 times)
0 Members and 1 Guest are viewing this topic.
Cyprus
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.


* Untitled.png (383.02 KB, 743x530 - viewed 19 times.)
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 509
Posts: 31462
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Edison Member
*
Karma: 30
Posts: 2313
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,
DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Cyprus
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Cyprus
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@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.
Code:
#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();
}
Logged

Offline Offline
Edison Member
*
Karma: 30
Posts: 2313
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,
DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Cyprus
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Its OK guys i figured it out. Thanks for the replies  smiley
Logged

Offline Offline
Edison Member
*
Karma: 30
Posts: 2313
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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)
Logged

Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,
DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Pages: [1]   Go Up
Jump to: