STEPPER MOTOR for Moving Tea Tray

Here is a good tutorial for a simple stepper motor set up, with wheel attached to 28BYJ-48 stepper motor and a driver board. If the power supply goes above 300mA it's better to use an external battery rather than drawing power directly from Arduino, which could cause damage to the board.

https://www.mschoeffler.de/2017/09/23/tutorial-how-to-drive-the-28byj-48-stepper-motor-with-a-uln2003a-driver-board-and-an-arduino-uno/

 

Use #include <Stepper.h> from Arduino library,

and the code below provided by Michael Schoeffler (link above to the original blog)


#define STEPS 2038 // the number of steps in one revolution of your motor (28BYJ-48)
Stepper stepper(STEPS, 8, 10, 9, 11);
void setup() {
  // nothing to do
}
void loop() {
  stepper.setSpeed(15); // 1 rpm
  stepper.step(2038); // do 2038 steps -- corresponds to one revolution in one minute
  delay(5000); // wait for one second
  stepper.setSpeed(15); // 6 rpm
  stepper.step(-2038); // do 2038 steps in the other direction with faster speed -- corresponds to one revolution in 10 seconds
}

 

28BYJ-48 stepper motor w driver board.jpg