Projects / Table-top robot that never falls off

Table-top robot that never falls off

Beginner1.5 hGuided buildReviewed

Build it step by step

0 of 6 done
  1. UNOROBOT+

    Assemble the chassis

    Fit the motors, wheels, caster and battery holder from the kit.

  2. UNO

    Mount the sensors

    Fix one at each front corner pointing down, 5 to 10 mm above the surface and just ahead of the wheels.

  3. UNO

    Wire the motor driver and Uno

    Follow the wiring table. Join all grounds.

  4. UNOROBOT

    Check sensor outputs

    With the robot on the table, note the DO level for each sensor over the table and over the edge, with a Serial print or the module's LED.

  5. UNO

    Set EDGE and speed

    Put EDGE to the level seen over nothing. Start with SPEED 140.

  6. UNOROBOT

    Test on a table

    Hold the robot near the edge and then let it drive. Put cushions on the floor first.

In short

How do you build a table-top robot that never falls off?

IR sensors pointing down see the table edge, and the robot backs up and turns before it drops. You need Arduino Uno R3, TCRT5000 IR reflective sensor module × 2, L298N Dual H-Bridge Module, Robot car chassis kit 2WD (acrylic), Battery holder 18650 2S (series), 18650 cell 2600 mAh (branded) × 2 and Jumper wires male to male (40 pcs, 20 cm). It takes 6 steps and about 90 minutes.

Level
Beginner
Time
About 90 min
Parts
7

Parts list

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

Wiring

FromToWhy
Left TCRT5000 OUTUno D2Left edge sensor
Right TCRT5000 OUTUno D3Right edge sensor
Both TCRT5000 VCC and GNDUno 5V and GNDSensor supply
L298N ENA, IN1, IN2Uno D5, D7, D8Left motor
L298N ENB, IN3, IN4Uno D6, D9, D10Right motor
Battery pack +L298N 12 V terminal and Uno VINMotor and board supply from two 18650 cells
Battery pack -L298N GND and Uno GNDCommon ground

Code

Arduino IDE, board "Arduino Uno". No libraries. The TCRT5000 modules have a small trimmer that sets the switching distance, and the output level over a surface versus over nothing differs between brands, so test and flip the EDGE constant.

Runs on a virtual Arduino Uno 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).

const byte LS = 2, RS = 3;                 // edge sensors
const byte ENA = 5, IN1 = 7, IN2 = 8, ENB = 6, IN3 = 9, IN4 = 10;
const byte SPEED = 140;
const int EDGE = HIGH;                       // module output level over nothing: check yours and flip if needed

void drive(int l, int r) {
  digitalWrite(IN1, l > 0); digitalWrite(IN2, l < 0);
  digitalWrite(IN3, r > 0); digitalWrite(IN4, r < 0);
  analogWrite(ENA, abs(l)); analogWrite(ENB, abs(r));
}

void setup() {
  for (byte p = 5; p <= 10; p++) pinMode(p, OUTPUT);
  pinMode(LS, INPUT); pinMode(RS, INPUT);
}

void loop() {
  bool left = digitalRead(LS) == EDGE, right = digitalRead(RS) == EDGE;
  if (left || right) {
    drive(0, 0); delay(100);
    drive(-SPEED, -SPEED); delay(300);                      // back away
    if (left && !right) drive(SPEED, -SPEED);               // edge on left: turn right
    else drive(-SPEED, SPEED);                              // edge on right or both: turn left
    delay(350 + random(300));
    drive(0, 0); delay(50);
  } else {
    drive(SPEED, SPEED);
  }
}

Test checklist

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

CheckExpected
Sensors over the tableLED on the module on, output at the surface level
Sensor held over the edgeOutput changes
Robot driving toward an edgeStops, reverses, turns, and continues
Ten minutes on a tableNever falls off

If it does not work

Robot drives off the edge

EDGE is the wrong level, the sensors are too high or the turn starts too late. Lower the speed.

Robot spins on the spot on the table

The sensor trimmers are set too sensitive for the table colour. Turn them back.

Wheels turn the wrong way

Swap the IN pins for that motor.

Sensor fooled by black tables

Black surfaces reflect little IR. Test the material first or use a different table.

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

Ask Lark AI

Common questions

What parts do I need for the table-top robot that never falls off?

Arduino Uno R3, TCRT5000 IR reflective sensor module × 2, L298N Dual H-Bridge Module, Robot car chassis kit 2WD (acrylic), Battery holder 18650 2S (series), 18650 cell 2600 mAh (branded) × 2 and Jumper wires male to male (40 pcs, 20 cm).

How long does the table-top robot that never falls off take to build?

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

How do I know the table-top robot that never falls off works?

Sensors over the table: LED on the module on, output at the surface level. Sensor held over the edge: Output changes. Robot driving toward an edge: Stops, reverses, turns, and continues.

Robot drives off the edge: what should I check?

EDGE is the wrong level, the sensors are too high or the turn starts too late. Lower the speed.

Robot spins on the spot on the table: what should I check?

The sensor trimmers are set too sensitive for the table colour. Turn them back.

Wheels turn the wrong way: what should I check?

Swap the IN pins for that motor.

Sensor fooled by black tables: what should I check?

Black surfaces reflect little IR. Test the material first or use a different table.