so I'm back and now with a little more knowledge under my belt, thanks for the link grumpy mike!
BUT... for some reason I still can't get the proper outcome, I know grumpy has said it's because of my delay's and it actually makes "sense" that they are not needed but without them the pan does a very sharp move then that's it.
here's my assumption on what's going on:
~ I'm creating my "current time"
~ I'm subtracting my current time from my "previous time" (which at the moment is zero)
~ if the statement is true it runs "pan servo"
this is the problem...
~ "pan servo" runs it's full cycle from the min-max-min degrees
~ loop starts over again running the motors then pan
... what I need it to do is move 1 degree "tag it's time", wait 10 millis, move to the next degree, etc... all while the other programs are running (in other words the panning need to be done in the background).
... it seems like I need to replace "delay" with somthing like "previous time" so it will tag it's time in 10 millisecond increments? If you have a look in the program you can see that I tried that but I get the error:
"Ivalue required as left operand of assignment"
I'm stumped once again, but in a god way! any help with this would be appreciated.
here's my code, I took out the motor commands to minimize the clutter.
#include <Servo.h>
Servo servo1;
long servoDelay = 10; // intervals at which to pan servo (milliseconds)
unsigned long previousTime; //represents the timing of the "cycle"
void setup()
{
unsigned long currentTime = millis();
if(currentTime - previousTime > servoDelay){ // if the time exceeds 10 milliseconds run "panServo"
panServo();
previousTime = currentTime; // "resets" the loop time
}
}
// pan servo funtions
void panServo()
{
for(int x=40; x<=140; x++){
servo1.write(x);
//delay (10);
millis() = previousTime;
}
for(int x=140; x>=40; x--){
servo1.write(x);
//delay (10);
millis() = previousTime;
}
}
thanks for looking ![]()