How to Make an Object Following Robot - the Stalkerbot




About: You either hate me or love me.


Speaking of mobile platforms, you might come up with ideas such as line tracking, obstacle avoidance, anti-dropping, environment monitoring, etc. But what I am making today, is a robot that follows an object, relentlessly. I call it the stalkerbot, and it is a lot of fun making this robot.

The basic function of this robot is simple: it follows you. It goes forward as you go forward; goes backward as you go backward; turns left/right as you turn left/right. When you stop moving, it stops as well.

I used two range sensors to identify the moving direction of object. You can also add more as well, but the minimum number that will do the job is two. The scenarios are quite straightforward, and will be explained later.

Material List

2wd miniQ Robot chassis from DFRobot

Upper Deck for miniQ from DFRobot

Infrared Sensor Switch from Ebay

Sharp GP2Y0A21 Distance Sensor (10-80cm) with mounting bracket from Ebay

Romeo All in one Controller from DFRobot

9g micro servo

7.4V lipo battery bar

screws, standoffs and cables


screw driver

soldering iron


Step 1: Assembling the Robot

I used a 2wd mobile platform “miniQ” and an extra deck from DFRobot. Assembling the lower chassis is quite intuitive, you can also check the video guide here.

Then solder the cables onto motor, and expand the lower chassis with standoffs and the upper deck.

Screw the Romeo controller onto the upper deck (you can also fix it in the middle of two layers), and connect the motor cables with M1 & M2 on the Romeo controller.

Make sure to leave some place for the lipo battery, you can either insert it between two layers, or tape it elsewhere from dropping off.

Step 2: Wiring the Sensors

Connect the two infrared sensor switch on digital port 8 and 9 on controller, and connect the Sharp distance sensor infrared distance sensor on analog port A1.

Please note that the infrared sensor switch is a digital sensor and should be connected to digital ports: green to GND, red to 5V, yellow to digital. While the Sharp distance sensor is an analog sensor and should be connected to analog ports: black to GND, red to 5V, orange to analog.

Step 3: Programming

There are five scenarios, basically.

If both sensors detect an object at the same time, and the distance is between 5 and 15 cm: object in range, just stop and check again.


If both sensors detect an object at the same time, and the distance is less than 5 cm: object too close, retreat to avoid impact.


If the left sensor detects an object while the right sensor does not: object at left, turn left and move forward.


If the right sensor detects an object while the left sensor does not: object at right, turn right and move forward.


If neither of the two sensors detects any object: not in sight, stay still and spin.

I've also enclosed the code for download. Below are explanations of some codes.


if(!left && !right && x>15)
{ advance(100,100); }

When digital infrared switch detects an obstacle, it generates low output; If not, generates high output.

The range of digital infrared sensor switch I used is 3~80cm, and the range can also be adjusted. Which is cool.


double get_gp2d120x (uint16_t value) {
if (value < 16) value = 16; return 2076.0 / (value - 11.0); }

This is to calculate the distance between IR sensor and the object.

Step 4: Epilogue

As for now, the tutorial for this object following robot has come to an end. Hope you all made it!

Next steps? Probably I will grab a mp3 module and a speaker, to make this quirky following robot more annoying - repeating "Penny, Penny" maybe? (I'm a TBBT fan).




    • Classroom Science Contest

      Classroom Science Contest
    • 1 Hour Challenge

      1 Hour Challenge
    • Beauty Tips Contest

      Beauty Tips Contest

    13 Discussions


    1 year ago

    Could you make this instruct-able complete (Explain why there is a servo and update the connections steps\diagram) & accurate (Romeo version is v1. If any one buy v2, then keep in mind that the pins have changed) ?


    1 year ago

    BTW, the video doesn't work now.


    2 years ago

    great robot, just one question. Could you use a battery holder with aa instead of the lipo but if not, where do you connect the battery?


    2 years ago

    how can i get more range of following, like around 5 meters? will infrared work for this range of operation?


    2 years ago

    why do you need the extra mini servos is there are already 2 servo included in the 2WD miniQ Robot Chassis?


    3 years ago

    could you please upload or give me the arduino wiring.


    3 years ago

    Hi it is a great project I was just wondering what can I use instead of the Romeo All in one Controller



    3 years ago

    Hey I need some help with project. i'll pay good ... ? i want to make a rc plane that has a object recognition and following that object (car, other rc plane, ...)

    whatever you need i'll provide

    vinu randula

    3 years ago on Introduction

    i have make this but i want to know how to connect micro servo to bord. my mail is


    4 years ago on Introduction

    Hey. can u send your full pdf to my mail

    Wow,really. Would you mind to share with me that what kind of builds you did for this kit? I have several of them also.But not quite sure which kind of project to do with... =. =

    When I was in college some friends and I made a "bug killer" game where we used the chassis for the "bug" that had IR sensors on it and the person playing had a "gun" with an IR LED in it that turned on with a trigger mechanism so when you "shot" the bug it would run away. It was pretty fun and we actually got a preliminary patent on it. This chassis worked really well because the positioning of the wheels made it very manuverable :)