This circuit is designed to control two stepper motors using an Arduino UNO. The circuit includes an A4988 driver for a bipolar stepper motor and a ULN2003 driver for a unipolar stepper motor. The Arduino UNO sends control signals to both drivers to manage the movement of the stepper motors. The power supply provides the necessary voltage for the components.
Arduino UNO
A4988 on Breakout Board
ULN 2003
28BYJ-48 Stepper Motor
Stepper Motor (Bipolar)
POWER SUPPLY 12V 5AMP
AC source
/*
* Arduino Sketch for Automatic Styrofoam Cutter
* This code controls two stepper motors using an A4988 driver and a ULN2003 driver.
* The A4988 driver controls a bipolar stepper motor, while the ULN2003 driver
* controls a unipolar stepper motor. The Arduino UNO is used to send control
* signals to both drivers. The code initializes the pins and runs a simple
* sequence to demonstrate the movement of the stepper motors.
*/
// Pin definitions for ULN2003 driver
#define IN1 8
#define IN2 9
#define IN3 10
#define IN4 11
// Pin definitions for A4988 driver
#define DIR_PIN 2
#define STEP_PIN 3
#define ENABLE_PIN 4
void setup() {
// Initialize serial communication
Serial.begin(9600);
// Set ULN2003 pins as outputs
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(IN3, OUTPUT);
pinMode(IN4, OUTPUT);
// Set A4988 pins as outputs
pinMode(DIR_PIN, OUTPUT);
pinMode(STEP_PIN, OUTPUT);
pinMode(ENABLE_PIN, OUTPUT);
// Enable A4988 driver
digitalWrite(ENABLE_PIN, LOW);
}
void loop() {
// Rotate unipolar stepper motor (ULN2003) one full cycle
for (int i = 0; i < 512; i++) {
stepUnipolar();
}
// Rotate bipolar stepper motor (A4988) one full cycle
digitalWrite(DIR_PIN, HIGH); // Set direction
for (int i = 0; i < 200; i++) {
stepBipolar();
}
delay(1000); // Wait for 1 second
}
void stepUnipolar() {
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW);
digitalWrite(IN4, LOW);
delay(2);
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
digitalWrite(IN3, LOW);
digitalWrite(IN4, LOW);
delay(2);
digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
delay(2);
digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW);
digitalWrite(IN4, HIGH);
delay(2);
}
void stepBipolar() {
digitalWrite(STEP_PIN, HIGH);
delayMicroseconds(1000);
digitalWrite(STEP_PIN, LOW);
delayMicroseconds(1000);
}
This code initializes the pins for the ULN2003 and A4988 drivers and runs a simple sequence to rotate both the unipolar and bipolar stepper motors. The stepUnipolar
function controls the ULN2003 driver, while the stepBipolar
function controls the A4988 driver. The main loop rotates each motor one full cycle and then waits for one second before repeating.