Build it step by step
0 of 6 doneWire the motor driver
Connect the MOSFET, diode, capacitor and gate pull-down.
Test the motor
Temporarily write the motor pin high and check the lift turns.
Build the lift
Fit a paddle or screw on the motor shaft and mount it at the end of the run.
Fit the sensor
Mount the IR sensor at the finish where each marble passes.
Wire the counter
Connect the TM1637 and the start button.
Run it
Drop marbles in and watch the lap count rise.
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
- Development BoardsBuyArduino Nano × 1
- Motors & ActuatorsBuy
- SemiconductorsBuyMOSFET IRLZ44N × 1
- SemiconductorsBuy
- SensorsBuy
- DisplaysBuy
- SwitchesBuy
- PassivesBuy
- PassivesBuyResistor 10 kΩ × 1
- PowerBuy
- BatteriesBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| 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 capacitor | Across the motor terminals | Smooths motor noise |
| Motor second terminal | MOSFET drain | Switched side |
| 1N4007 diode | Cathode to motor +, anode to MOSFET drain | Flyback diode |
| Nano D9 | MOSFET gate and 10 kΩ to GND | Lift motor |
| IR obstacle sensor VCC, GND, OUT | Nano 5V, GND, D3 | Marble sensor, OUT goes low when a marble passes |
| TM1637 CLK, DIO | Nano D6, D7 | Lap counter |
| TM1637 VCC, GND | Nano 5V, GND | Power |
| Button | Nano D2 and GND | Start 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.
| Check | Expected |
|---|---|
| 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 |
| Start again | Counter 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 →
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.
