Measure Movement on Timer

I have been looking and Google every variant I could think of?. I am so frustrated. Maybe there is no solution.
I am trying to figure out a way to determine if a human has stopped moving. I need to figure out if you have not moved in a 5 minute span and if true turn LED off. Is this possible? First I need to figure out a timer of 5 minutes and then interface a gyro or accelerometer or something else? This seem very simple but I have no threads that even come close to a solution.
Any ideas of how I should go about this?

Thanks

Stopped moving for 5 minutes? Wouldn't that require the human to be deceased? (In which case, a heart monitor is the best choice.)

Once you have decided how you detect or define movement, the program is easy. Assuming you wrote a magic function detectMove which returns 0 or false if no movement was detected you can use some simple code like this (based on Blink Without Delay Tutorial):

const int ledPin =  13;      // the number of the LED pin
const unsigned long interval = 30000L;           // 30 seconds of no movement is good

int detectMove() {
// Here's your magic movement detection function
if ( ... detect some movement ...) {
   return 1;
}
else {
   return 0;
}
}

void setup() {
  // set the digital pin as output:
  pinMode(ledPin, OUTPUT);      
}

void loop() {
  static unsigned long previousMillis = 0;        // will store last time LED was updated
  unsigned long currentMillis = millis();
  if (detectMove ()) {
     // Turn off light and reset timer when movement is detected
    previousMillis = currentMillis;  
    digitalWrite(ledPin, LOW);
  }
  else {
      if(currentMillis - previousMillis > interval) {
         // Turn led on
        digitalWrite(ledPin, HIGH);
     }
  }
}

(As usual, the code is untested, all errors are up to you to fix)

I guess the tougher part will be to decide that no movement occurred, but that I leave to you.

Korman

I am trying to figure out a way to determine if a human has stopped moving.

I'll agree with the others. You need to define what "not moving" means. Velocity is a change in location OR direction. Zero velocity can be achieved only when there is not change in location or direction.

No change in location will require a GPS to determine.

No change in direction will require multiple accelerometers to determine. And, given the rules you mentioned in your other post, this is not the condition that you are seeking to detect.

'Velocity is a change in location OR direction'
Being pedantic, I have to say that this is not true
Velocity is a change in location (displacement) AND direction.
Velocity is a vector quantity; one must specify magnitude and direction.

Dang yes a GPS is the way to go! I wonder if I could just measure one direction of a accelerometer to measure if no change in 5 minutes, when the GPS has no fix (say the GPRMC)?

Great answers got me thinking out of the (my) box.

Thanks guys!!!

GPS won't work if you want to detect if someone has been sitting on the toilet for more than 5 minutes. You really should go ahead and tell us what kind of movement you're interested in. Is it someone not tossing around in his sleep, someone sitting on the toilet, someone not leaving the school-yard, an actor keeping immobile as a human statue? Those are all kind of not moving, and all of them would require different solutions. Out of the box thinking is only of value if you know that either you're in the wrong box or that your box is empty. Otherwise it's better to investigate the box properly first.

Korman

Well there is a two part solution. Where I work, we have a school house where there are multiple phases of training, multiple events that deal with time and accuracy. We have a 5, 10 and 20 mile land navigation course. In the past we have had guys that struggle and some guys that are super gifted these gifted guys will run the entire way and nap for spell then cross the finish line just in time. The idea is to complete it as fast as you can and not stay in one location for longer than 5 minutes. We have instructors that shadow different groups on ATVs and try to catch the slackers and help the wounded. The idea is if you are wounded you activate your strobe light; if you are a slacker the strobe light activates itself. We would still need to measure this when there is no GPS feed.?. I hope this helps. The other part is silly. The idea was that one of the guys wife falls asleep with a headlamp, she is jittery while awake reading, doing puzzles and such. When she falls asleep she will roll over in the night and shine her lamp in his face. We just told him to tell her to sleep on the couch.

Are there any other forums that are helpful?

Are there any other forums that are helpful?

Maybe, but they probably don't like the same question cross-posted multiple times in the same forum.

Seriously, what have you tried, and what didn't work that you felt the need to bump?

There was a thread about this exact problem a few days ago IIRC.

I would think an accerometer on the ankle would be the most practical method. Granted someone could sit down and wave their leg about, but how far do you want to go?


Rob