Guides · 10 min read

Arduino Elevator Project: 3-Floor Model with Stepper and Servo

Arduino elevator project guide: 28BYJ-48 stepper cabin, 3 call buttons, reed floor sensors, 7-segment floor display, servo door and collective call logic.

An Arduino elevator project is one of the most popular school fair builds, and one of the few that teaches motor control, sensor reading, driving a display and decision logic all at once. In this guide we build a three-floor model with an Arduino Uno: a 28BYJ-48 stepper motor lifts the cabin by winding a string, a reed switch on each floor reports that the cabin has arrived, three floor buttons place calls, a single-digit 7-segment display shows the floor number and a small SG90 servo opens and closes the cabin door.

The most instructive part of the project is not the mechanics but the software. A real elevator does not work in the order the buttons were pressed but by direction: going up it collects the calls on its way and turns around when nothing is left in that direction. We explain this behaviour with a call order table and then write the code as a state machine. That way the buttons keep being read while the motor turns, the door opens smoothly and the cabin stops safely if a sensor fails.

28BYJ-48 stepper motor and ULN2003 driver board
The 28BYJ-48 stepper motor and ULN2003 driver board that lift the cabin

How does an elevator model work?

The heart of the model is the stepper motor that pulls the cabin up on a string. The string is wound on a small spool on the motor shaft; when the motor turns one way the cabin rises, the other way it goes down. Because a stepper turns a fixed angle per step, we can estimate how far the cabin has travelled by counting steps, but since the string stretches and the spool can slip, the real position comes from the floor sensors. The Arduino keeps listening to the buttons and sensors, decides which floor to go to, drives the motor, writes the floor on the display and opens the door when the cabin stops.

PartJobNote
Arduino UnoThe brain that makes every decisionAll 18 pins are used
28BYJ-48 + ULN2003Raises and lowers the cabin on a string5 V, about 200 mA
3 reed switches + magnetReport which floor the cabin is onMagnet on the cabin, reeds on the shaft
3 push buttonsGround, 1st and 2nd floor callsTo GND with internal pull-up
Common cathode 7-segmentShows the floor number220 Ω resistor per segment
SG90 servoOpens and closes the cabin doorFrom the external 5 V supply
5 V 2 A adapterPowers the motor and servoGND shared with the Arduino
Cardboard, foam board or MDFElevator shaft and cabinShaft 5 mm wider than the cabin inside

Mechanics: cabin, spool and counterweight

The 28BYJ-48 is small but, thanks to its gearbox, strong: it delivers about 34 mN·m of torque at the output shaft. On a 30 mm spool the radius is 15 mm, so the pull on the string is 0.034 ÷ 0.015 ≈ 2.3 N, roughly 230 grams. Allowing for speed and friction, we recommend keeping the cabin plus load under 100 grams. The same spool winds 94 mm of string per turn; since the motor makes a full turn in 4096 half-steps, at a 1.2 ms step interval one turn takes about 4.9 seconds and the cabin moves about 19 mm per second. With 12 cm between floors, one floor takes about 6 seconds, which makes the model look realistic and fun to watch.

  • Guide the cabin in the shaft with two vertical rails (straws, aluminium rods or angle profile); otherwise it rotates and rubs on the walls.
  • Wind enough string on the spool and tie the end to it; even with the cabin on the ground floor, two turns should remain on the spool.
  • A counterweight close to the cabin's weight (a small box of coins) wound the opposite way on the spool with a second string brings the motor load close to zero.
  • Use braided string or thin fishing line instead of monofilament; monofilament stretches and the cabin bounces slightly when it stops.
  • When the coils are switched off, the 64:1 gearbox mostly holds the cabin in place; if a heavy cabin slides down, add a counterweight.

Wiring diagram: Arduino Uno pins

This design uses all 18 Arduino Uno pins apart from serial: the 12 digital pins D2 to D13 and the 6 analog pins A0 to A5. Using analog pins as digital inputs is completely normal; writing pinMode(A0, INPUT_PULLUP) is enough. Since the buttons and reed switches use the internal pull-up resistors, no external resistor is needed: one side goes to the pin, the other to GND, and the pin reads LOW when pressed.

PartPart pinArduino Uno pin
ULN2003 driverIN1, IN2, IN3, IN4D8, D9, D10, D11
ULN2003 driver+ / −External 5 V / GND
Ground, 1st and 2nd floor buttonOne leg (other to GND)A0, A1, A2
Ground, 1st and 2nd floor reed switchOne end (other to GND)A3, A4, A5
7-segment (common cathode)a, b, c, d, e, f, gD2, D4, D5, D6, D7, D12, D13 (each through 220 Ω)
7-segment (common cathode)Common pinGND
SG90 servoOrange signalD3
SG90 servoRed / brownExternal 5 V / GND
Do not power the stepper and servo from the Arduino's 5V pin. The motor draws about 200 mA and the servo can draw more than 500 mA while moving; that drops the USB voltage and makes the Arduino reset by itself. Power both from a separate 5 V 2 A adapter, always connect the adapter's GND to the Arduino's GND and add a 470 µF capacitor across the servo supply.

Floor sensors: reed, Hall or infrared

Glue a small neodymium magnet to the side of the cabin and place a reed switch on the inner wall of the shaft at each floor. When the cabin reaches that floor, the magnet pulls the two contacts inside the reed's glass together, the circuit closes and the pin goes LOW. Depending on the magnet, a reed switch detects from 5 to 15 mm away, so keep the gap between magnet and reed to a few millimetres. A Hall sensor or an infrared obstacle sensor can do the same job; which one you pick depends on your model's materials and budget.

SensorProsConsWiring
Reed switchCheap, needs no power, two wiresFragile glass body, wide detection zonePin and GND, INPUT_PULLUP
Hall sensor (A3144)Robust, sharp detectionMagnet pole must face the right way5 V, GND, output to pin
Infrared obstacle sensorNo magnet neededAffected by ambient light, needs tuning5 V, GND, output to pin
Micro limit switchExact position, very cheapMechanical contact, makes noisePin and GND, INPUT_PULLUP

Calibration: measure the steps between floors

  1. Build the shaft, fit the cabin on its rails and wind the string on the spool; move the cabin by hand slightly above the ground floor.
  2. Wire the motor, sensors and power as in the pin table; the buttons and 7-segment are not needed for this step.
  3. Upload the calibration code below and open the Serial Monitor at 9600 baud.
  4. Type d and press Enter; the cabin should go down. If it goes up, swap the IN1 and IN4 wires or set UP_DIR to -1 in the main code.
  5. The code stops when the cabin reaches the ground floor; now send u and note the step count printed each time the cabin reaches a floor.
  6. Write about 1.5 times the largest value into the MAX_STEPS constant in the main code.
C++ (Arduino IDE)
1// Asansör maketi kalibrasyon: kabini Seri Port'tan sür, katlar arası adım sayısını ölç
2// Elevator model calibration: drive the cabin from Serial, measure steps between floors
3// Komutlar / commands: u = yukarı / up, d = aşağı / down, s = dur / stop
4
5const byte COIL[4] = {8, 9, 10, 11};      // ULN2003 IN1..IN4
6const byte FLOOR_SENSOR[3] = {A3, A4, A5}; // Kat 0, 1, 2 reed anahtarları / floor 0, 1, 2 reed switches
7const unsigned int STEP_US = 1200;         // Yarım adım aralığı (µs) / half-step interval (µs)
8
9// 28BYJ-48 yarım adım dizisi / 28BYJ-48 half-step sequence
10const byte SEQ[8][4] = {
11  {1, 0, 0, 0}, {1, 1, 0, 0}, {0, 1, 0, 0}, {0, 1, 1, 0},
12  {0, 0, 1, 0}, {0, 0, 1, 1}, {0, 0, 0, 1}, {1, 0, 0, 1}
13};
14
15int dir = 0;              // +1 yukarı, -1 aşağı, 0 duruyor / +1 up, -1 down, 0 stopped
16byte phase = 0;           // Dizideki konum / position in the sequence
17long steps = 0;           // Son kattan beri adım / steps since the last floor
18int lastFloor = -1;       // Son görülen kat / last floor seen
19unsigned long lastStep = 0;
20
21void coilsOff() {
22  for (byte i = 0; i < 4; i++) digitalWrite(COIL[i], LOW); // Bobinleri boşalt / release the coils
23}
24
25void stepOnce() {
26  phase = (phase + (dir > 0 ? 1 : 7)) % 8; // İleri ya da geri bir yarım adım / one half-step forward or back
27  for (byte i = 0; i < 4; i++) digitalWrite(COIL[i], SEQ[phase][i]);
28  steps++;
29}
30
31int floorNow() {
32  for (byte f = 0; f < 3; f++) {
33    if (digitalRead(FLOOR_SENSOR[f]) == LOW) return f; // Mıknatıs karşısında / magnet in front
34  }
35  return -1;
36}
37
38void setup() {
39  Serial.begin(9600);
40  for (byte i = 0; i < 4; i++) pinMode(COIL[i], OUTPUT);
41  for (byte f = 0; f < 3; f++) pinMode(FLOOR_SENSOR[f], INPUT_PULLUP);
42  coilsOff();
43  Serial.println(F("u = yukari/up, d = asagi/down, s = dur/stop"));
44}
45
46void loop() {
47  if (Serial.available()) {
48    char c = Serial.read();
49    if (c == 'u') { dir = 1;  steps = 0; Serial.println(F("Yukari / up")); }
50    if (c == 'd') { dir = -1; steps = 0; Serial.println(F("Asagi / down")); }
51    if (c == 's') { dir = 0;  coilsOff(); Serial.println(F("Dur / stop")); }
52  }
53
54  if (dir != 0 && micros() - lastStep >= STEP_US) {
55    lastStep = micros();
56    stepOnce();
57  }
58
59  int f = floorNow();
60  if (f >= 0 && f != lastFloor) {
61    lastFloor = f;
62    Serial.print(F("Kat / floor "));
63    Serial.print(f);
64    Serial.print(F("  adim / steps: "));
65    Serial.println(steps);
66    steps = 0;
67    if ((f == 2 && dir > 0) || (f == 0 && dir < 0)) { dir = 0; coilsOff(); } // Uçta dur / stop at the ends
68  }
69}

This code drives the motor with our own eight-entry half-step sequence instead of the Stepper library. Every 1200 microseconds it moves to the next pattern, and that wait is done with a micros() comparison rather than delay(), so the Serial port and sensors keep being read while the motor turns. The number you measure depends on the spool diameter and floor height: with a 30 mm spool and 12 cm between floors you should see about 5200 half-steps. Don't worry if the values differ by a few hundred steps between floors; the spool diameter grows a little as string winds on.

Call order (queue) logic

The first idea that comes to mind is to write the button presses into a queue and send the cabin there one by one. This is called FIFO (first in, first out) and it works for a one-person model, but in a real building it gives silly results: the cabin ignores the floor on its way, goes to the far floor first and then comes back. Real elevators use collective control: when the cabin travels in one direction it collects every call in that direction on its way and changes direction only when no calls are left. The SCAN algorithm used by disk read heads is the same idea. The table below shows the difference with concrete examples.

Cabin statePress orderFIFO queueCollective (this code)
At ground, idle2, then 10 → 2 → 1 (passes 1 and comes back)0 → 1 → 2 (stops at 1 on the way)
At 2nd floor, idle0, then 1 while going down2 → 0 → 12 → 1 → 0
Going up from 1st floor0, then 21 → 0 → 21 → 2 → 0 (finishes its direction first)
At 1st floor, door open1 (same floor)Reopens the doorExtends the waiting time
At 1st floor, door closing1 (same floor)Door closes, then opensDoor reopens at once

State machine: the elevator's brain

An elevator has to do several things at once: read buttons while the motor turns, record a new call while the door opens, close the door when time runs out. Code that uses delay() can do none of these at the same time. The solution is to split the program into a few clear states and, on every loop() pass, move only the current state's work forward a little. If this is new to you, have a look at the Arduino state machine and millis() vs delay() articles. Our elevator's seven states and their transitions are:

StateWhat it doesNext state
HOMINGAt start-up, if the floor is unknown, lowers the cabin to the ground floorIDLE when the ground sensor triggers, otherwise FAULT
IDLEChecks the calls and picks a directionDOOR_OPENING if there is a call on this floor, MOVING if on another
MOVINGDrives the motor step by step, watches the floor sensorsDOOR_OPENING at a called floor, FAULT if the step limit is exceeded
DOOR_OPENINGSlowly turns the servo from 0° to 90°DOOR_WAITING when the door is open
DOOR_WAITINGKeeps the door open for 3 secondsDOOR_CLOSING when time runs out
DOOR_CLOSINGTurns the servo back to 0°IDLE when closed, DOOR_OPENING if the same floor's button is pressed
FAULTStops the motor, shows E on the displayOnly a reset gets out of it

Arduino elevator code (full version)

C++ (Arduino IDE)
1// Arduino asansör maketi: 3 kat, step motor, kapı servosu, 7 segment kat göstergesi
2// Arduino elevator model: 3 floors, stepper motor, door servo, 7-segment floor display
3#include <Servo.h>
4
5const byte COIL[4] = {8, 9, 10, 11};                  // ULN2003 IN1..IN4
6const byte CALL_BTN[3] = {A0, A1, A2};                 // Kat çağrı butonları / floor call buttons
7const byte FLOOR_SENSOR[3] = {A3, A4, A5};             // Kat sensörleri (reed) / floor sensors (reed)
8const byte SEG[7] = {2, 4, 5, 6, 7, 12, 13};           // a, b, c, d, e, f, g (ortak katot / common cathode)
9const byte DOOR_PIN = 3;                               // Kapı servosu / door servo
10
11const unsigned int STEP_US = 1200;        // Yarım adım aralığı / half-step interval
12const long MAX_STEPS = 9000;              // Bir kat için en fazla adım (kalibrasyonla ayarla) / max steps per floor
13const int UP_DIR = 1;                     // Kabin ters gidiyorsa -1 yap / set to -1 if the cabin runs backwards
14const byte DOOR_CLOSED = 0, DOOR_OPEN = 90; // Servo açıları / servo angles
15const unsigned long DOOR_WAIT = 3000;     // Kapı açık bekleme (ms) / door open time (ms)
16
17const byte SEQ[8][4] = {
18  {1, 0, 0, 0}, {1, 1, 0, 0}, {0, 1, 0, 0}, {0, 1, 1, 0},
19  {0, 0, 1, 0}, {0, 0, 1, 1}, {0, 0, 0, 1}, {1, 0, 0, 1}
20};
21// Rakam desenleri (bit0 = a ... bit6 = g) / digit patterns
22const byte DIGIT[3] = {0b0111111, 0b0000110, 0b1011011}; // 0, 1, 2
23const byte SYM_E = 0b1111001, SYM_DASH = 0b1000000;
24
25enum State { HOMING, IDLE, MOVING, DOOR_OPENING, DOOR_WAITING, DOOR_CLOSING, FAULT };
26State state = HOMING;
27
28Servo door;
29bool calls[3] = {false, false, false}; // Bekleyen çağrılar / pending calls
30int floorNow = -1;                     // Kabinin bulunduğu kat / current floor
31int dir = 0;                           // +1 yukarı, -1 aşağı / +1 up, -1 down
32byte phase = 0;
33long stepsSinceFloor = 0;
34int doorAngle = DOOR_CLOSED;
35unsigned long tStep = 0, tDoor = 0, tWait = 0;
36
37void show(byte pattern) {
38  for (byte i = 0; i < 7; i++) digitalWrite(SEG[i], bitRead(pattern, i));
39}
40
41void coilsOff() {
42  for (byte i = 0; i < 4; i++) digitalWrite(COIL[i], LOW);
43}
44
45void stepMotor() {
46  if (micros() - tStep < STEP_US) return;
47  tStep = micros();
48  phase = (phase + (dir * UP_DIR > 0 ? 1 : 7)) % 8;
49  for (byte i = 0; i < 4; i++) digitalWrite(COIL[i], SEQ[phase][i]);
50  stepsSinceFloor++;
51}
52
53int readSensors() {
54  for (byte f = 0; f < 3; f++) if (digitalRead(FLOOR_SENSOR[f]) == LOW) return f;
55  return -1;
56}
57
58bool callAbove() { for (int f = floorNow + 1; f < 3; f++) if (calls[f]) return true; return false; }
59bool callBelow() { for (int f = floorNow - 1; f >= 0; f--) if (calls[f]) return true; return false; }
60
61// Toplayıcı (SCAN) mantığı: yönü koru, o yönde çağrı kalmayınca dön
62// Collective (SCAN) logic: keep the direction, reverse when no calls remain that way
63int chooseDir() {
64  if (dir > 0 && callAbove()) return 1;
65  if (dir < 0 && callBelow()) return -1;
66  if (callAbove()) return 1;
67  if (callBelow()) return -1;
68  return 0;
69}
70
71void setState(State s) {
72  state = s;
73  Serial.print(F("Durum / state: "));
74  Serial.print(s);
75  Serial.print(F("  kat / floor: "));
76  Serial.println(floorNow);
77}
78
79void readButtons() {
80  // Sıçrama zararsız: çağrı yalnızca true yapılır / bounce is harmless: a call is only set true
81  for (byte f = 0; f < 3; f++) if (digitalRead(CALL_BTN[f]) == LOW) calls[f] = true;
82}
83
84bool moveDoor(int target) { // Kapıyı 15 ms'de 1 derece sür / move the door 1 degree every 15 ms
85  if (millis() - tDoor < 15) return false;
86  tDoor = millis();
87  if (doorAngle < target) doorAngle++;
88  else if (doorAngle > target) doorAngle--;
89  door.write(doorAngle);
90  return doorAngle == target;
91}
92
93void setup() {
94  Serial.begin(9600);
95  for (byte i = 0; i < 4; i++) pinMode(COIL[i], OUTPUT);
96  for (byte i = 0; i < 7; i++) pinMode(SEG[i], OUTPUT);
97  for (byte f = 0; f < 3; f++) {
98    pinMode(CALL_BTN[f], INPUT_PULLUP);
99    pinMode(FLOOR_SENSOR[f], INPUT_PULLUP);
100  }
101  door.attach(DOOR_PIN);
102  door.write(DOOR_CLOSED);
103  coilsOff();
104  show(SYM_DASH);
105
106  floorNow = readSensors();
107  if (floorNow >= 0) { show(DIGIT[floorNow]); setState(IDLE); }
108  else { dir = -1; setState(HOMING); } // Kat bilinmiyor: zemine in / floor unknown: go to ground
109}
110
111void loop() {
112  readButtons();
113  int s = readSensors();
114
115  switch (state) {
116    case HOMING:
117      stepMotor();
118      if (s == 0) { floorNow = 0; dir = 0; coilsOff(); show(DIGIT[0]); setState(IDLE); }
119      else if (stepsSinceFloor > 3 * MAX_STEPS) { coilsOff(); show(SYM_E); setState(FAULT); }
120      break;
121
122    case IDLE:
123      if (calls[floorNow]) { calls[floorNow] = false; setState(DOOR_OPENING); break; }
124      dir = chooseDir();
125      if (dir != 0) { stepsSinceFloor = 0; setState(MOVING); }
126      break;
127
128    case MOVING:
129      stepMotor();
130      if (s >= 0 && s != floorNow) {          // Yeni kata gelindi / reached a new floor
131        floorNow = s;
132        stepsSinceFloor = 0;
133        show(DIGIT[floorNow]);
134        if (calls[floorNow]) {                // Bu katta çağrı var / a call on this floor
135          calls[floorNow] = false;
136          coilsOff();
137          setState(DOOR_OPENING);
138        } else if (chooseDir() != dir) {       // Bu yönde iş kalmadı / nothing left this way
139          coilsOff();
140          setState(IDLE);
141        }
142      } else if (stepsSinceFloor > MAX_STEPS) { // Sensör gelmedi: güvenli dur / no sensor: safe stop
143        coilsOff();
144        dir = 0;
145        show(SYM_E);
146        setState(FAULT);
147      }
148      break;
149
150    case DOOR_OPENING:
151      if (moveDoor(DOOR_OPEN)) { tWait = millis(); setState(DOOR_WAITING); }
152      break;
153
154    case DOOR_WAITING:
155      if (calls[floorNow]) { calls[floorNow] = false; tWait = millis(); } // Butona basılırsa bekle / hold the door
156      if (millis() - tWait >= DOOR_WAIT) setState(DOOR_CLOSING);
157      break;
158
159    case DOOR_CLOSING:
160      if (calls[floorNow]) { calls[floorNow] = false; setState(DOOR_OPENING); break; } // Yeniden aç / reopen
161      if (moveDoor(DOOR_CLOSED)) setState(IDLE);
162      break;
163
164    case FAULT:
165      break; // Reset tuşuna basılana kadar bekle / wait for the reset button
166  }
167}

You don't need to install any extra library; the Servo library comes with the Arduino IDE. The calls array holds whether there is a pending call for each floor. The buttons are read on every pass and the pressed floor's call is set to true; since a call is only ever set to true, button bounce does no harm, so no separate debounce code is needed. The chooseDir() function is the whole collective logic: if the cabin is going up and there is a call above, it keeps going up, the same for down, and when that direction is done it looks the other way. In the MOVING state, when the cabin sees a new floor sensor, the code first checks for a call on that floor; if there is one, the motor stops and the door opens. If there is no call and the direction to go has changed, the cabin moves to IDLE without opening the door.

  • STEP_US: the step interval. Below 1000 the 28BYJ-48 may skip steps; try 1500 for a heavy cabin.
  • MAX_STEPS: the maximum number of steps allowed per floor. If a sensor fails or the string breaks, the motor will not turn forever.
  • DOOR_WAIT: how long the door stays open, in milliseconds.
  • DOOR_OPEN and DOOR_CLOSED: the servo angles. If the door slides instead of swinging, tie a wire to the servo horn and push the door sideways.
  • coilsOff(): cuts the current to the coils when the cabin stops; the motor and ULN2003 stay cool and the adapter's load drops.

Door safety: the most important rule in real elevators is that the cabin never moves while the door is open. The state machine in this code guarantees that by design: the motor only steps in the MOVING state, and MOVING is only entered through IDLE once the door is fully closed. Instead of writing 90° to the servo in one go, the door turns one degree every 15 ms; a full opening takes about 1.4 seconds and there is less noise and shaking. If that floor's button is pressed while the door is closing, the door reopens immediately; this is a simple version of the door light curtain in real elevators. Finally, the MAX_STEPS limit acts as a safety lock: if the cabin doesn't reach a new floor in the expected time, the motor stops and E appears on the display.

7-segment floor display

In a single-digit display every segment is a separate LED, and each one connects to a pin through its own 220 Ω resistor. At 5 V about (5 − 2) ÷ 220 ≈ 13 mA flows through a red segment; with all seven lit the total stays around 95 mA, which is safe for the Uno. In the code each digit is stored as one byte: bit 0 is segment a and bit 6 is segment g. If your display is common anode, connect the common pin to 5 V and invert the bitRead result in show(). See the 7-segment display article for details and the LED resistor calculator for the resistor value.

ShownLit segmentsByte in codeMeaning
0a b c d e f0b0111111Ground floor
1b c0b00001101st floor
2a b d e g0b10110112nd floor
Ea d e f g0b1111001Fault (FAULT)
-g0b1000000Searching for floor (HOMING)

Ideas to extend the project

  • Add a keypad or three more buttons inside the cabin; hall calls and cabin calls can share the same calls array.
  • Solve the pin shortage with a 74HC595 shift register; the 7-segment drops to three pins and frees room for direction arrow LEDs.
  • Play a "First floor" announcement at each floor with a DFPlayer Mini.
  • Put an HC-SR04 distance sensor at the top of the shaft to measure the cabin position continuously and show the centimetres.
  • For a bigger model use a NEMA 17 motor and an A4988 driver; you only need to rewrite stepMotor() for the STEP and DIR pins.
  • Add a real light curtain: an infrared sensor at the cabin entrance that stops the door from closing while something is in the way.

Common problems and fixes

SymptomLikely causeFix
Motor vibrates but doesn't turnIN1–IN4 order mixed up or step interval too shortCheck the wires against D8–D11, set STEP_US to 1500
Cabin goes the wrong wayCoil wiring reversedSet the UP_DIR constant to -1
Display shows EReed doesn't detect the magnet or MAX_STEPS too smallMove the magnet closer to the reed, repeat the calibration
Arduino resets when the door opensServo current pulls down the USB supplyPower the servo from external 5 V, add a 470 µF capacitor
Cabin stops a few millimetres above the floorWide reed detection zoneMove the magnet down a little or use a smaller magnet
Digits look garbledCommon anode display or different segment orderConnect the common pin to 5 V, invert the pattern, check the a–g order
One button never worksTwo legs on the same side of the button are wiredWire the button across its diagonal legs
Before fitting everything inside the model, build the circuit on a breadboard and test the code by triggering the reed switches by hand with the magnet. Watching the state changes in the Serial Monitor is the fastest way to tell logic errors from mechanical problems.

Because the elevator model combines a stepper, a servo, sensors, a display and decision logic in one build, it is one of the best ways to test what you have learned. In the BlueGrays app you can find step-by-step circuit diagrams and code for projects such as using a stepper motor, a servo motor, a counter with a 7-segment display, controlling an LED with a button and a reed switch door sensor, so you can try every part of this model on its own first.

Frequently asked questions

Which motor is used for an Arduino elevator project?

For small models the 28BYJ-48 stepper with a ULN2003 driver is the cheapest and easiest option; thanks to its gearbox it easily lifts a cabin of up to 100 grams. Bigger, heavier models usually use a NEMA 17 stepper with an A4988 driver or a geared DC motor with an encoder.

How does an elevator model know which floor the cabin is on?

The simplest way is to glue a magnet to the cabin and put a reed switch at each floor. When the cabin reaches that floor, the reed closes and the Arduino pin reads LOW. A Hall sensor, an infrared obstacle sensor or a micro limit switch does the same job.

How is the order of elevator calls decided?

Real elevators use collective control: when the cabin travels in one direction it picks up every call in that direction on the way and turns around only when none are left. A FIFO queue that follows the order of button presses is simpler but sends the cabin back and forth for no reason.

How many pins does a 7-segment display need in an elevator model?

A single-digit 7-segment display has seven segment pins plus a common pin, not counting the decimal point, so it needs seven Arduino pins. If you run out of pins, a 74HC595 shift register brings it down to three pins and a TM1637 module to two.

Why shouldn't elevator code use delay()?

While delay() runs, the Arduino can do nothing else; it can't read buttons while the motor turns and misses new calls while the door opens. A state machine that measures time with millis() and micros() moves everything forward in small steps at the same time.

How long does a 28BYJ-48 take to climb one floor?

That depends on the spool diameter and step rate. With a 30 mm spool and a 1.2 ms step interval the cabin moves about 19 mm per second, so it climbs a 12 cm floor in about 6 seconds. Going below a 1 ms step interval can make the motor skip steps.

See all projects
LED Control with a Push Button (Push)
AR-9Beginner

LED Control with a Push Button (Push)

Just like a doorbell: the light stays on as long as you press, and goes off when you let go.

4.8(120)
288
Using a Stepper Motor
AR-67Intermediate
Premium

Using a Stepper Motor

A motor that turns step by step, exactly as far as you want, like the hand of a clock.

4.5(31)
42
Using a Servo Motor
AR-35Beginner
Premium

Using a Servo Motor

The arm of a small servo motor turns to three positions in turn: all the way to the start, right to the middle and all the way to the end, waiting two seconds at each stop.

4.7(49)
69
Displaying Numbers 0-9 on a 7-Segment Display
AR-41Intermediate
Premium

Displaying Numbers 0-9 on a 7-Segment Display

Write those familiar numbers you see in elevators and digital clocks yourself. On a display made of seven little light bars, the Arduino shows a digit from 0 to 9, one each second, and then starts…

4.5(30)
43
Counter with 7-Segment Display and Buttons
AR-43Advanced
Premium

Counter with 7-Segment Display and Buttons

A simple counter with three buttons: press one and the digit on the display goes up by one, press another and it goes down by one, and the third sends it back to zero.

4.6(35)
47
Reading a Reed Switch
AR-37Beginner

Reading a Reed Switch

Ever wondered about the magnetic switch inside door and window alarms? When a magnet comes near the reed relay module, the tiny switch inside it closes; the Arduino reads it once a second and prints…

4.4(23)
31
Reed Switch Door Sensor
AR-38Beginner
Premium

Reed Switch Door Sensor

Tell whether your door is open or closed just by looking at a light. You attach a small magnet to the door and a magnet-sensing switch to the frame; when the door is closed they sit side by side and…

4.7(34)
44
360-Degree Servo from a Stepper Motor
AR-68Intermediate
Premium

360-Degree Servo from a Stepper Motor

Teach an ordinary stepper motor to go to any angle you want, all the way around the circle.

4.5(22)
33