0% found this document useful (0 votes)
4 views

Steppertxt

This document contains code to control a 28BYJ-48 stepper motor using an Arduino UNO and ULN2003 driver board. The code defines the motor pins, initializes the AccelStepper library to control the motor in half step mode at a maximum speed of 1000 steps per second, and runs the motor at a constant speed of 500 steps per second.

Uploaded by

Ashlie Jane
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Steppertxt

This document contains code to control a 28BYJ-48 stepper motor using an Arduino UNO and ULN2003 driver board. The code defines the motor pins, initializes the AccelStepper library to control the motor in half step mode at a maximum speed of 1000 steps per second, and runs the motor at a constant speed of 500 steps per second.

Uploaded by

Ashlie Jane
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

/*

Example sketch to control a 28BYJ-48 stepper motor


with ULN2003 driver board, AccelStepper and Arduino UNO:
continuous rotation. More info: https://www.makerguides.com
*/

// Include the AccelStepper library:


#include "AccelStepper.h"

// Motor pin definitions:


#define motorPin1 8 // IN1 on the ULN2003 driver
#define motorPin2 9 // IN2 on the ULN2003 driver
#define motorPin3 10 // IN3 on the ULN2003 driver
#define motorPin4 11 // IN4 on the ULN2003 driver

// Define the AccelStepper interface type: 4 wire motor in half step mode:
#define MotorInterfaceType 8

// Initialize with pin sequence IN1-IN3-IN2-IN4


AccelStepper stepper = AccelStepper(MotorInterfaceType, motorPin1, motorPin3,
motorPin2, motorPin4);

void setup() {
// Set the maximum steps per second:
stepper.setMaxSpeed(1000);
}

void loop() {
// Set the speed of the motor in steps per second:
stepper.setSpeed(500);
// Step the motor with constant speed as set by setSpeed():
stepper.runSpeed();
}

You might also like