Arduino Mega 2560 Controlled Multi-Stepper Motor System with OLED Display and Push Buttons
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit is designed to control a system with three stepper motors, eight push buttons, two potentiometers, and an OLED display using an Arduino Mega 2560. The system has three modes of operation, each activated by a long press of a specific button. The potentiometers are used to control the speed of the motors, and the OLED display shows relevant information such as speed in RPM, motor angles, and operation count.
Component List
Bipolar Stepper Motor (NEMA 17)
- Pins: A-, A+, B+, B-
- Description: A bipolar stepper motor used for precise control of rotational position.
Stepper Motor (Bipolar)
- Pins: D, B, C, A
- Description: A bipolar stepper motor used for precise control of rotational position.
A4988 Stepper Motor Driver (Red)
- Pins: ENABLE, MS1, MS2, MS3, RESET, SLEEP, STEP, DIR, VMOT, GND, 2B, 2A, 1A, 1B, VDD
- Description: A stepper motor driver used to control the bipolar stepper motors.
Arduino Mega 2560
- Pins: IOREF, RESET, 3V3, 5V, GND, VIN, A0-A15, D0-D53, AREF, SDA, SCL
- Description: A microcontroller board based on the ATmega2560, used to control the entire system.
8 Push Button Board PCB
- Pins: K1, K2, K3, K4, K5, K6, K7, K8, GROUND
- Description: A PCB with 8 push buttons used for user input.
Push Button Round
- Pins: leg0, leg1
- Description: A single round push button used for additional user input.
MKE-M04 Potentiometer Module
- Pins: GND, 5V, SIG
- Description: A potentiometer module used to control the speed of the motors.
OLED Display 2.42"
- Pins: GND, VCC, SCK, SDA, RES, DC, CS
- Description: An OLED display used to show relevant information such as speed in RPM, motor angles, and operation count.
Battery 38.5V 24Ah
- Pins: Out +ve, Out -ve
- Description: A battery used to power the stepper motor drivers.
Wiring Details
Bipolar Stepper Motor (NEMA 17)
- A- connected to 1B of A4988 Stepper Motor Driver (Red)
- A+ connected to 1A of A4988 Stepper Motor Driver (Red)
- B+ connected to 2A of A4988 Stepper Motor Driver (Red)
- B- connected to 2B of A4988 Stepper Motor Driver (Red)
Stepper Motor (Bipolar)
- D connected to 1A of A4988 Stepper Motor Driver (Red)
- B connected to 1B of A4988 Stepper Motor Driver (Red)
- C connected to 2A of A4988 Stepper Motor Driver (Red)
- A connected to 2B of A4988 Stepper Motor Driver (Red)
A4988 Stepper Motor Driver (Red)
- STEP connected to D4 PWM of Arduino Mega 2560
- DIR connected to D5 PWM of Arduino Mega 2560
- VMOT connected to Out +ve of Battery 38.5V 24Ah
- GND connected to Out -ve of Battery 38.5V 24Ah
- VDD connected to 5V of Arduino Mega 2560
Arduino Mega 2560
- D4 PWM connected to STEP of A4988 Stepper Motor Driver (Red)
- D5 PWM connected to DIR of A4988 Stepper Motor Driver (Red)
- D6 PWM connected to STEP of A4988 Stepper Motor Driver (Red)
- D7 PWM connected to DIR of A4988 Stepper Motor Driver (Red)
- D2 PWM connected to STEP of A4988 Stepper Motor Driver (Red)
- D3 PWM connected to DIR of A4988 Stepper Motor Driver (Red)
- GND connected to GND of MKE-M04 Potentiometer Module
- A0 connected to SIG of MKE-M04 Potentiometer Module
- D21/SCL connected to SCK of OLED Display 2.42"
- D20/SDA connected to SDA of OLED Display 2.42"
- D16 PWM/TX2 connected to leg0 of Push Button Round
- D15/RX3 connected to K8 of 8 Push Button Board PCB
- D14/TX3 connected to K7 of 8 Push Button Board PCB
- D8 PWM connected to K1 of 8 Push Button Board PCB
- D9 PWM connected to K2 of 8 Push Button Board PCB
- D10 PWM connected to K3 of 8 Push Button Board PCB
- D11 PWM connected to K4 of 8 Push Button Board PCB
- D12 PWM connected to K5 of 8 Push Button Board PCB
- D13 PWM connected to K6 of 8 Push Button Board PCB
- GND connected to leg1 of Push Button Round
- GND connected to GROUND of 8 Push Button Board PCB
8 Push Button Board PCB
- K1 connected to D8 PWM of Arduino Mega 2560
- K2 connected to D9 PWM of Arduino Mega 2560
- K3 connected to D10 PWM of Arduino Mega 2560
- K4 connected to D11 PWM of Arduino Mega 2560
- K5 connected to D12 PWM of Arduino Mega 2560
- K6 connected to D13 PWM of Arduino Mega 2560
- K7 connected to D14/TX3 of Arduino Mega 2560
- K8 connected to D15/RX3 of Arduino Mega 2560
- GROUND connected to GND of Arduino Mega 2560
Push Button Round
- leg0 connected to D16 PWM/TX2 of Arduino Mega 2560
- leg1 connected to GND of Arduino Mega 2560
MKE-M04 Potentiometer Module
- GND connected to GND of Arduino Mega 2560
- 5V connected to 5V of Arduino Mega 2560
- SIG connected to A0 of Arduino Mega 2560
OLED Display 2.42"
- GND connected to GND of Arduino Mega 2560
- VCC connected to 5V of Arduino Mega 2560
- SCK connected to D21/SCL of Arduino Mega 2560
- SDA connected to D20/SDA of Arduino Mega 2560
Battery 38.5V 24Ah
- Out +ve connected to VMOT of A4988 Stepper Motor Driver (Red)
- Out -ve connected to GND of A4988 Stepper Motor Driver (Red)
Code Documentation
/*
* This Arduino sketch controls a system with 3 stepper motors, 8 push buttons,
* 2 potentiometers, and an OLED display. The system has 3 modes of operation,
* each activated by a long press of a specific button. The potentiometers are
* used to control the speed of the motors, and the OLED display shows relevant
* information such as speed in RPM, motor angles, and operation count.
*/
#include <AccelStepper.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
// Define stepper motor connections and interface type
AccelStepper stepper1(AccelStepper::DRIVER, 2, 3);
AccelStepper stepper2