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

Arduino UNO Controlled Stepper Motor Elevator with 7-Segment Floor Display

View and Edit Project In Cirkit DesignerImage of Arduino UNO Controlled Stepper Motor Elevator with 7-Segment Floor Display

Circuit Documentation

Summary

This circuit is designed to control a stepper motor using an Arduino UNO microcontroller. The stepper motor is intended to move an elevator between four floors, with the current floor number displayed on a 7-segment display. The circuit includes a stepper motor driver to interface the Arduino with the stepper motor, pushbuttons for floor selection, resistors for pull-up configurations, a ceramic capacitor for noise reduction on the motor power supply, and a power supply to drive the motor. Additionally, the circuit integrates an HX711 weighing sensor module with a SparkFun Load Cell Amplifier for potential weight measurement applications.

Component List

Microcontroller

Motors

Motor Drivers

Power Supply

Passive Components

Input Devices

Output Devices

Sensors

Wiring Details

Arduino UNO

Nema 17 42-STH48 Stepper Motor

A4988 Stepper Motor Driver (Red)

Power Supply

Ceramic Capacitor

Pushbuttons

Resistors

7-Segment Display

SparkFun Load Cell Amplifier - HX711

HX711 Weighing Sensor Module

Documented Code

/*
 * Four Floors Elevator Project
 * This code controls a stepper motor to move an elevator to different floors
 * based on button presses. The current floor number is displayed on a 7-segment
 * display.
 */

// Pin definitions
const int dirPin = 4;
const int stepPin = 2;
const int buttonPins[] = {8, 9, 10, 11};
const int segmentPins[] = {3, 5, 6, 7, 12, 13, A0};
const int stepsPerRevolution = 200;
const int stepsPerFloor = 50; // Adjust based on your setup

void setup() {
  pinMode(dirPin, OUTPUT);
  pinMode(stepPin, OUTPUT);
  for (int i = 0; i < 4; i++) {
    pinMode(buttonPins[i], INPUT_PULLUP);
  }
  for (int i = 0; i < 7; i++) {
    pinMode(segmentPins[i], OUTPUT);
  }
  displayFloor(0); // Start at floor 0
}

void loop() {
  for (int i = 0; i < 4; i++) {
    if (digitalRead(buttonPins[i]) == LOW) {
      moveToFloor(i);
      displayFloor(i);
      delay(1000); // Debounce delay
    }
  }
}

void moveToFloor(int floor) {
  int steps = floor * stepsPerFloor;
  digitalWrite(dirPin, HIGH); // Set direction
  for (int i = 0; i < steps; i++) {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(500);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(500);
  }
}

void displayFloor(int floor) {
  const byte numbers[4][7] = {
    {HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, LOW}, // 0
    {LOW, HIGH, HIGH, LOW, LOW, LOW, LOW}, // 1
    {HIGH, HIGH, LOW, HIGH, HIGH, LOW, HIGH}, // 2
    {HIGH, HIGH, HIGH, HIGH, LOW, LOW, HIGH} // 3
  };
  for (int i = 0; i < 7; i++) {
    digitalWrite(segmentPins[i], numbers[floor][i]);
  }
}

This code is responsible for controlling the stepper motor and displaying the floor number on the 7-segment display based on the button inputs. It initializes the pins, sets up the pull-up resistors for the buttons, and defines the functions for moving to a floor and displaying the floor number.