Let's Make Robots!

Smooth Object Tracking

head follows an object around the room
foureyes.bas1.89 KB

I was looking for a way to have a robots head follow something or someone around. The best results I found were the ones using a camera, but these are a bit expensive to my taste. I've seen some robots that have a servo with an IR-sensor on top that finds either the left or the right edge of anything you put in front of it. I toyed around with that, but I got frustrated with a few things.

If you follow the left edge of an object, the robot allways seem to look slightly left past the object instead of in the middle. Also:When the edge is detected, the servo goes from left to right and back between detecting the object and looking past it.  

 So I came up with the idea to have two IR sensors inside the head that can move (rotate) by themselves: independant of the head. The sensors detect the edges and provide information as to whether to turn the head left or right. The head doesn't need to move back and forth as much to detect the edges, giving it a much smoother object tracker.

 I wanted to do this with a picaxe 08M to make "smart eyes". The bots mainboard can than communicate with the 08M to obtain more info than just the range from the eyes. but of course I had to try it out first. Also: with the 08M hooked up to 2 servos and 2 analog sensors that leaves only 1 input pin and no outputs. Oh well.


This test setup was done "the Frits! way": i.e. with paintsticks and double sided tape and a few paperclips.

The top servo pushes the eyes outward and pulls them inward. The bottom servo rotates the "head".

The algorithm is simple.


  • Pull the eyes inwards and turn the head in the direction of the eye that detects an object.
  • If both eyes see an object start pushing outward
  • Turn the head in the direction of the eye that detects an edge (=no object in sight) 
  • If both eyes lost sight of the object, go back to pulling inward.


The servos are a bit jerky, but the same servos work fine in Edward, so it is probably due to lack of caps or underpowering of the servos. 

As you can see in the video (sorry for the poor quality) the eyes are moving back and forth, but the head is steady.

Future improvements


  • Make it smaller!
  • Put the eyes inside a head so you wont see them moving so much.
  • Expand the  program to determine object width or width of a possible escape route for the bot
  • Put everything in a small independent package. I want this to become an "intelligent" sensor you can just hook up to a bot using serial or I2C or something. 
  • Add vertical axis



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Just got back to this, it is still billiant! Cant believe no one has copied yet!

Hey mint,

I am building a version of this sensor as we speak. I got it quite a bit smaller but still quite limited to the servo size. Alas, no money for micro ones... At any rate, I will post what I got as soon as I get her running.

--And I could not agree more about the 08M thing... It would have been sweet to have a stand-alone unit with just a couple of output leads. I guess a 14M isn't too much bigger, but a little tiny 8-leg guy and micro servos would be a lot cooler.

--Much love for posting the code.

I don't realy know what the micro servos cost over there, but the servos I used are €5.00  (about $8). Don't know the name for their size.

Now these aren't very good quality, but of the 8 nylon gear servos i bought for €5 each, none broke. I also bought 2 metal geared servos the same size for $16 a piece (excl shipping) and one of them broke the first day.

Can't wait to see  your sensor.  

Been thinking about your design alot and hope to incorporate it in my Laser RF MkIII.  In the meantime have you considered having just a single sensor being aimed up/down with one servo, left/right with another so that it moves in a circular motion and attempt to keep the object within the circle, changing how big the circular motion is to suit the size of the object.

I'm building a simplified version now. No range capability just a laser/sensor setup to detect the absense/presence of an object. Will post video when done.

actually I have considered using a single sensor with a circular motion, but I'm afraid a setup like that takes too long to find the object when it moves out of sight. Especially if the object moves fast and is further away.

Right now i'm thinking about the fritsLDR / amandaLDR but with 4 or 5 sensors aranged in a star. If the object moves away, you can tell in which direction it moved by determining which sensor lost track of it first. Perhaps the range or precision can be improved by a lens (or lenses).

That way you don't need to find edges. The "eye" could hold still as long as all sensors see the object.

Sounds like the compound eyes of an insect. I believe those motion sensors used to turn on lights or trip alarms work on this principle.

Have you seen this example of LEDS being used to make a compound eye/touch sensor? 

I made an IR Fritz LDR, see my tip/walkthrough "making the most of your ADC" or something like that, includes schematic for simple 1 transistor amplifier. Phototransistors have a built in lens, are more sensitive and respond quicker than LDR's

I had good sensitivity for about 150mm but with some tweaking should do a lot better. 

I was gonna ask where to get a phototransistor, but I guess i'll check out the pololu things first ;)
Have you made any progress with your latest variation of the motion tracker? I'm making one now with my IR version of a FritsLDR.

Sorry. No. I was going to make a smaller one with the sensors mounted vertically and a less sloppy way to mount the servo. Then Chris said he was gonna build one and he usually posts a cool video a couple of hours after that. So I decided to wait and started on something else.

Right now i'm working on a way to get a 08M picaxe to be the brain for the eyes. More specifically: I'm working on a 1 or 2 line serial bus to have three 08M picaxes talk to each other.