Projects / Marble run with motor lift

Marble run with motor lift

Beginner3 hGuided buildReviewed

Build it step by step

0 of 6 done
  1. NANOIRLZ44

    Wire the motor driver

    Connect the MOSFET, diode, capacitor and gate pull-down.

  2. NANO

    Test the motor

    Temporarily write the motor pin high and check the lift turns.

  3. NANO

    Build the lift

    Fit a paddle or screw on the motor shaft and mount it at the end of the run.

  4. NANO

    Fit the sensor

    Mount the IR sensor at the finish where each marble passes.

  5. NANO12:45

    Wire the counter

    Connect the TM1637 and the start button.

  6. NANO

    Run it

    Drop marbles in and watch the lap count rise.

In short

How do you build a marble run with motor lift?

A geared motor lifts marbles back to the top of a cardboard run, and a sensor counts each lap. You need Arduino Nano, TT gear motor 3 to 6 V, MOSFET IRLZ44N, Rectifier Diode 1N4007, IR obstacle avoidance sensor module, TM1637 4-digit display, Tactile push button 6 mm, Electrolytic Capacitor 100 µF, Resistor 10 kΩ, Battery holder 4 × AA with switch and AA alkaline battery × 4. It takes 6 steps and about 180 minutes.

Level
Beginner
Time
About 180 min
Parts
11

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
4 AA holder +Motor red, Nano VIN and capacitor +About 6 V supply
4 AA holder -MOSFET source, Nano GND and capacitor -Common ground
100 µF capacitorAcross the motor terminalsSmooths motor noise
Motor second terminalMOSFET drainSwitched side
1N4007 diodeCathode to motor +, anode to MOSFET drainFlyback diode
Nano D9MOSFET gate and 10 kΩ to GNDLift motor
IR obstacle sensor VCC, GND, OUTNano 5V, GND, D3Marble sensor, OUT goes low when a marble passes
TM1637 CLK, DIONano D6, D7Lap counter
TM1637 VCC, GNDNano 5V, GNDPower
ButtonNano D2 and GNDStart the lift

Code

Arduino IDE, board "Arduino Nano" (processor ATmega328P, or ATmega328P (Old Bootloader) for clones). Install "TM1637" by Avishay Orpaz. The TT gear motor is rated 3 to 6 V, so four fresh AA cells (6.4 V) is the upper end; use three cells if it runs hot. Make the lift from a paddle wheel or screw of card or plastic and keep fingers clear of the moving parts. The logic-level IRLZ44N switches fully from a 5 V pin. Marbles are a choking hazard for young children, so supervise play.

Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

#include <TM1637Display.h>

TM1637Display display(6, 7);               // CLK, DIO
const byte MOTOR = 9, SENSOR = 3, START = 2;
const unsigned long EMPTY_MS = 30000UL;    // stop the lift if no marble for 30 s
unsigned int laps = 0;
bool running = false;
unsigned long lastMarble = 0;

void setup() {
  pinMode(MOTOR, OUTPUT);
  pinMode(SENSOR, INPUT);
  pinMode(START, INPUT_PULLUP);
  display.setBrightness(5);
  display.showNumberDec(0);
}

void loop() {
  if (!digitalRead(START)) {
    running = true; laps = 0; lastMarble = millis();
    display.showNumberDec(laps);
    delay(300);
  }
  digitalWrite(MOTOR, running);

  if (running && digitalRead(SENSOR) == LOW) {          // a marble crossed the beam
    laps++;
    lastMarble = millis();
    display.showNumberDec(laps);
    while (digitalRead(SENSOR) == LOW) {}               // wait for the beam to clear
    delay(100);
  }
  if (running && millis() - lastMarble > EMPTY_MS) running = false;   // run is empty
}

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Press startMotor runs and the display shows 0
Marble passes the sensorCount goes up by one
No marble for 30 sLift stops
Start againCounter resets and the lift restarts

If it does not work

Motor never starts

Check the gate wire and the battery.

Counts twice per marble

Add a longer debounce or move the sensor.

Counts nothing

Adjust the sensor's potentiometer and check OUT on D3.

Nano resets when the motor starts

Put a 100 µF capacitor across the motor and keep wires short.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the marble run with motor lift?

Arduino Nano, TT gear motor 3 to 6 V, MOSFET IRLZ44N, Rectifier Diode 1N4007, IR obstacle avoidance sensor module, TM1637 4-digit display, Tactile push button 6 mm, Electrolytic Capacitor 100 µF, Resistor 10 kΩ, Battery holder 4 × AA with switch and AA alkaline battery × 4.

How long does the marble run with motor lift take to build?

About 180 minutes for a beginner maker, in 6 steps.

How do I know the marble run with motor lift works?

Press start: Motor runs and the display shows 0. Marble passes the sensor: Count goes up by one. No marble for 30 s: Lift stops.

Motor never starts: what should I check?

Check the gate wire and the battery.

Counts twice per marble: what should I check?

Add a longer debounce or move the sensor.

Counts nothing: what should I check?

Adjust the sensor's potentiometer and check OUT on D3.

Nano resets when the motor starts: what should I check?

Put a 100 µF capacitor across the motor and keep wires short.