Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino Mega 2560 Stepper Motor Controller with LCD Display and Keypad

View and Edit Project In Cirkit DesignerImage of Arduino Mega 2560 Stepper Motor Controller with LCD Display and Keypad

Circuit Documentation

Summary

This circuit is designed to control a stepper motor using a DM542T driver, an Arduino Mega 2560, an LCD display, a membrane keypad, and a rotary encoder. The user can set the rotation angle and speed of the stepper motor using the keypad. The current angle and speed are displayed on the LCD. The rotary encoder is used to fine-tune the angle.

Component List

  1. Stepper Motor (Bipolar)

    • Pins: D, B, C, A
    • Description: A bipolar stepper motor used for precise control of angular position.
  2. Arduino Mega 2560

    • Pins: IOREF, RESET, 3V3, 5V, GND, VIN, A0-A15, D21/SCL, D20/SDA, D19/RX1, D18/TX1, D17 PWM/RX2, D16 PWM/TX2, D15/RX3, D14/TX3, D0 RX0, D1 TX0, D2 PWM, D3 PWM, D4 PWM, D5 PWM, D6 PWM, D7 PWM, D8 PWM, D9 PWM, D10 PWM, D11 PWM, D12 PWM, D13 PWM, AREF, SDA, SCL, D52, D50, D48, D46, D44, D42, D40, D38, D36, D34, D32, D30, D28, D26, D24, D22, D53, D51, D49, D47, D45, D43, D41, D39, D37, D35, D33, D31, D29, D27, D25, D23
    • Description: A microcontroller board based on the ATmega2560.
  3. Lcd 20x4 i2c

    • Pins: GND, 5V, SCA, SCL
    • Description: A 20x4 character LCD display with I2C interface.
  4. Membrane Matrix Keypad

    • Pins: Row 1, Row 2, Row 3, Row 4, Column 1, Column 2, Column 3
    • Description: A membrane keypad used for user input.
  5. STEPPERONLINE DM542T

    • Pins: B-, B+, A-, A+, +V, GND, PUL+, PUL-, DIR+, DIR-, ENA+, ENA-, ALM+, ALM-
    • Description: A stepper motor driver.
  6. Rotary Encoder incremental type side mount

    • Pins: A, B, Z, VCC, GND
    • Description: An incremental rotary encoder used for fine-tuning the angle.
  7. DC Power Source

    • Pins: Ground, Positive
    • Description: A DC power source for powering the circuit.

Wiring Details

Stepper Motor (Bipolar)

Arduino Mega 2560

Lcd 20x4 i2c

Membrane Matrix Keypad

STEPPERONLINE DM542T

Rotary Encoder incremental type side mount

DC Power Source

Code Documentation

/*
 * This Arduino sketch controls a stepper motor using a DM542T driver, an LCD
 * display, a membrane keypad, and a rotary encoder. The user can set the
 * rotation angle and speed of the stepper motor using the keypad. The current
 * angle and speed are displayed on the LCD. The rotary encoder is used to
 * fine-tune the angle.
 */

#include <Keypad.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// Keypad setup
const byte ROWS = 4; // Four rows
const byte COLS = 3; // Three columns
char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
};
byte rowPins[ROWS] = {32, 34, 36, 38}; // Connect to the row pinouts of the keypad
byte colPins[COLS] = {40, 42, 44}; // Connect to the column pinouts of the keypad
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);

// LCD setup
LiquidCrystal_I2C lcd(0x27, 20, 4); // Set the LCD address to 0x27 for a 20x4 display

// Rotary encoder setup
const int encoderPinA = 3;
const int encoderPinB = 2;
volatile int encoderValue = 0;

// Stepper motor driver pins
const int stepPin = 7;
const int dirPin = 8;
const int enablePin