tracking motion

Hello, I'd like to use a motion sensor(s) to track motion and feedback to a motor that would turn to follow the motion.

Is this easy or hard? Does anyone know of any info/tutorials for doing this?

Also should I use a servo or stepper motor?

I'm fairly new to Arduino so think I may be running before I can walk but thought I'd ask.

Thanks in advance. Steve

I think we need a little more info on this one .-)

When you say track motion, do you men just discover that someone is moving or do you mean actually tracking the direction of a person moving ?

And what about " feedback to a motor that would turn to follow the motion" is tha a motor on the floor that follows a person or a motor that sits in a fixed place and turns to follow the person ?

Hello MikMo,

I’d like the motor to stay put and turn to follow the person. It needs to follow the movement not just discover it. As an example: the motor could be inside a doll’s head and the sensor(s) attached to the side or top and the head would move to follow the motion.

Hope this makes it a bit clearer.


If you mean a "motion sensor" like this sort of device, you're probably out of luck.

These can tell that something is moving in the room, but they can't tell you where the moving object is, nor what direction the moving object is moving.

The best chance of success is with a video camera, and with enough processing power to study the differences between old frames and current new frames of the input imagery.

At a minimum*, to make a doll's head track a moving object (as if looking at it), you need three sensors. We'll call them left, middle and right. You have to turn the head until the middle sensor is aligned with the target, and then if either of the left or right sensors see the target coming into view, then your program knows which way to turn the head to try to get the target back in the middle.

  • There is a two-sensor scheme if your sensor can already discover if it is on the left or to the right edge of the target. Line-following robots use this scheme. This can even be a one-sensor scheme if you allow the sensor to be jittered back and forth like a pigeon's head (that's actually why pigeons jitter their head, to improve their non-stereo depth perception).


This is NOT a trivial task! I agree with halley - a video camera with frame grab is your best bet, which means that Arduino is NOT your best bet! Good luck with it - I hope you find a suitable solution.

Thanks everyone for your input.

I had a feeling it might be harder than it seemed.

what you/we need is a port of the CMU-Cam project to Arduino though it looks like about 4x more memory and more CPU power might be required.

Maybe a much lower resolution configuration might still work and fit in the Arduino memory and power footprint. Another option might be to combine a wireless I/F and offload some of the processing to a remote PC like the CMU-Cam1 and v2 did. It looks like CMU-Cam3 has everything done onboard the ARM7 CPU. If anything, it should give you an idea of what it might take to do a tracking system and if Arduino is up to the task.

This guy uses a cmucam for tracking on an arduino based robot ..

COuld you not use multiple sensors, e.g. sonar or infra-red? As long as the head didn't need to cover 360 degrees, then a series of sensors covering lets say 45 degrees, would be able to detect movement and depending on which of those set of sensors had been activated would also be able to tell the direction of movement and therefore turn the head in that direction?

I agree with Mike, a standard solution for finding anything moving, and where its moving, is triangulation.

Generally speaking, something getting further from sensor A and getting closer to sensor B means it's moving in a direction indicated as away from A and towards B (left or right, depending on the relationship between the two).

Of course, if the two sensors are on the same axis (plane) this becomes more difficult without knowing how much they are blocking sensor A or B. This can be resolved by reducing the resolution of an individual sensor, and increasing the total number of sensors. For example, a matrix of photodiodes with a 1-degree field-of-view could be utilized - you see which ones are blocked now, and which ones are blocked in the next check. You could tell direction by the changes in the matrix.


Hi everyone,

Thanks for all the great comments and suggestions.

My original and very vague thought was to have two distance sensors like the Sharp GP2Y0A21YK0F on the left and right, because they’re analogue I could get the measurement from them both. If they both read the same this would mean(hopefully) that the object is equally between them and if one reading is higher/lower I could get the motor to move until the measurement is back to being equal. I’m sure there is probably some fundamental flaw in this but it seemed to make sense in my head at the time.

I had a quick look at the cmucam and it seems like it could be the answer especially as it’s been linked to an Arduino, thanks for the links JakesSA and Dougl.

I’m pretty new to the Arduino so am going to work through some easier stuff and my Making Things Talk book first. I may also mess about with the idea of the Sharp distance sensors before the cmucam as they’ll be a lot cheaper.

Thanks again for the suggestions, I’ll be sure to post my results when I finally get on to the project.

Have a good Christmas everyone…

Your first post almost sounded like you wanted to build an inertial measurement unit. Which is something that has been tickling my interests as well.

for remote sensing (aerial photography, google street view, etc) you need to know where you are in absolute position, and you need to know your attitude. There are IMU's of all sorts out there, with the high performance commercial ones being from applanix and weighing in at a cool $500K.

The concept of operation in a lot of these is that they have a gyro of some sort that determines attitude, and the gyro output is fine tuned from GPS points as the platform moves. Some of the less expensive units use MEMs accelerometers and GPS tuning of accelerometer output. Integrating the accelerometer output will yield velocity, and integrating again with yield position. Both of which can be updated from subsequent GPS readings. And all the hardware is available cheaply (to some level of precision) for the arduino platform. The question is how fast the Arduino can do the math.


I'd personally do this:

\ | / \ | / Sensors> A B C | | Dolls head> | ( o ) | \ / '------'

Where \ | / are the angles the sensors are facing and ( o ) is a motor/servo mounted underneath the dolls head, we could ask sensor A if it has noticed any change, if not, we ask B, and so on. If sensor C has detected motion, and we are not currently facing in Cs direction, we would turn accordingly, were B to detect motion next, we would be able to deduce that the subject is moving left, and we would turn the motor in that direction and PAST that point, however if within a short period of time A had not detected movement, we would quickly turn back to sensor Bs direction. The sensors would have to be mounted on the dolls body, and as such as many sensors as you want could be used to further increase the accuracy of the dolls facing direction.

tl;dr If a sensor detects motion, it turns to the defined angle of that sensor.

Hope it helps a little, -Archive

Apologies if my diagram looks somewhat like a breast-monster. :D

I have to admit that was teh first thing that went through my mind :-[

Depends what you mean by track motion
You have the following options

  1. Use a PIR sensor to tell if there is any motion at all ( but not really know where it is )
  2. Track a certain color using a CMUcam or AVRcam or Blackfin Robot Camera
  3. Use a Devantech Heat Sensor Array to track humans or animals

Thanks for the idea Archive (and the Breast Monster!).

I've just got a copy of Physical Computing by Tom Igoe and Dan O'Sullivan. There's a section in there about tracking. There's an example written in Processing using a webcam which I'm going to mess about with. It also talks about the CMU Cam.

I have had the same idea but to use it as a rocket system. Yes it sounds weird but it really is awsome. Though I have no Arduino experince and this is my first post, it will take a long time to get this up and running. I want to complete it in a year or less.

My basic idea is to use two servos, one to point the rocket in 360 degrees of control, and another to point it up to 80 degrees high. The main idea is that it will;

1) Detect movement 2) Follow movement 3) Fire rocket

Nice and simple. But not really. The rocket is a modle rocket (purchased at a hobbie shop) witch I already own. It is fired electronicly. The rocket it packed with explosives from fireworks. The rocket is already built and I am purchasing my Arduino in a week.

I might have design scetches up here soon. I am also thinking that this should be remote controled as well as atonomous.

Thanks for reading! Check here for updated info and PM me if you want to help me with this project!