Circuit Documentation
Summary
This circuit involves an Arduino UNO microcontroller controlling a stepper motor. The Arduino provides the necessary control signals to the stepper motor to drive it in both directions. Additionally, a servo motor is controlled by the Arduino to move between specified angles.
Component List
Stepper Motor
- Component Name: Stepper Motor One
- Description: A stepper motor that is controlled by the Arduino to rotate in both directions.
- Pins: IN1, IN2, IN3, IN4, +, -
Arduino UNO
- Component Name: Arduino UNO
- Description: A microcontroller board based on the ATmega328P. It provides the control signals to the stepper motor and the servo motor.
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
Wiring Details
Stepper Motor One
- Pin IN1 connected to Arduino UNO Pin D4
- Pin IN2 connected to Arduino UNO Pin D5
- Pin IN3 connected to Arduino UNO Pin D6
- Pin IN4 connected to Arduino UNO Pin D7
- Pin + connected to Arduino UNO Pin 5V
- Pin - connected to Arduino UNO Pin GND
Arduino UNO
- Pin 5V connected to Stepper Motor One Pin +
- Pin GND connected to Stepper Motor One Pin -
- Pin D4 connected to Stepper Motor One Pin IN1
- Pin D5 connected to Stepper Motor One Pin IN2
- Pin D6 connected to Stepper Motor One Pin IN3
- Pin D7 connected to Stepper Motor One Pin IN4
Code Documentation
Arduino UNO Code
#include <Stepper.h>
#include <Servo.h>
#define OUTPUT1 4
#define OUTPUT2 5
#define OUTPUT3 6
#define OUTPUT4 7
Servo servo;
const int stepsPerRotation = 2048; //
Stepper myStepper(stepsPerRotation, OUTPUT1, OUTPUT3, OUTPUT2, OUTPUT4);
void setup() {
servo.attach(8);
servo.write(90);
myStepper.setSpeed(15); // RPM (Round Per Minute)
}
void loop() {
myStepper.step(stepsPerRotation);
delay(500);
servo.write(0);
delay(500);
myStepper.step(-stepsPerRotation);
delay(500);
servo.write(180);
delay(500);
}
This code initializes a stepper motor and a servo motor. The stepper motor is controlled to rotate in both directions, while the servo motor moves between 0, 90, and 180 degrees. The setup() function initializes the servo motor to 90 degrees and sets the speed of the stepper motor. The loop() function continuously rotates the stepper motor and moves the servo motor between specified angles with delays in between.
