IM LIMITED WITH TIME! Servo motor controlling

Hello, i have school project to make servo motor controlled with potentiometer, and i did that, but now i need to add in this program command with this function: if sevo motor is not moving for some time, then he needs to automaticaly turn to 90 degrees, i dont know how to write command with this function. Please help.
Here is my code who only controls servo with potentiometer:

#include <Servo.h> 

int outputValue = 0;

Servo servo1;

void setup() {
 servo1.attach(2);

}

void loop() {
  outputValue = analogRead(A0);
  int angleValue = map(outputValue, 0, 1023, 0, 180);
  servo1.write(angleValue);
}

If I understand your problem correctly you need to record the time (millis() ) whenever the potentiometer value changes. Then you can do something else if there is a long gap after the most recent move.

Code like this should do the job

btnVal = digitalRead(btnPin);
if (btnVal == HIGH) {    // assumes btn is LOW when pressed
   lastBtnPressMillis = millis();   // btn not pressed so reset clock
}
if (millis() - lastBtnPressMillis > = interval) {
   // button has been pressed for longer than interval
}

You just need to change it so that instead of

if (btnVal == HIGH)

you have

if (potVal != prevPotVal)

...R

Thank you very much :slight_smile:

A servomotor is normally something like this: http://www.alibaba.com/product-detail/Panasonic-ac-servo-motor-a4-series_1979862644.html

A hobby servo is more correctly a small self-contained servomechanism. OK, that means it contains
a small servo motor I suppose, but I thought for a moment you had a more ambitious project there!