Panning A Camera

Hello All you Arduino Pros,
I’m working on a project and am using the Arduino for the first time. I am a total novice at this so please be kind.

My project involves moving a camera 270 degrees back and forth three times every four minutes. I have a servo running back and forth and can stop it for a while between sweeps, however, by using “Delay” I can do nothing else. I’ve looked at Timer.h, SoftTimer, State Machines and AccelStepper to find a way to accomplish my project and am now so confused that I don’t know which way to go. I would really appreciate one of you well experienced folks’ help.

What I want to do is the following:
1 I have a light sensor and would like the program to “check” it every 10 mins looking for a “HIGH”.
2 When a HIGH is detected, I want the servo to sweep 0 to 180 degrees, then 180 to 0 degrees three times EVERY 5 mins.
3 WHILE the servo is sweeping I need a pin to go HIGH (turns on the camera) BUT only while the servo sweeps.
4 Finally, I want this to go on until the light sensor returns a LOW.

I have tried some different things using “servo.h” with no success, would one or more of you please suggest a Library and some code that will accomplish my goal???

I would really appreciate any help I can get.

This is the Programming forum, where you are expected to post your code. If you need Project Guidance, you should have gone there.

however, by using “Delay” I can do nothing else

Look at the "blink without delay" example code for ideas. Also you should post your code if you want help with it.

OK,

I did look at the Blink with out delay and I have tried the following sketch:

/* This example code is in the public domain.

 
 http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay
 */

// set pin numbers:
const int ldrPin =  2;      // the number of the LDR pin
const int lsrPin =  6;      // the number of the LIGHT pin

Servo myservo;  // create servo object to control a servo


// Variables will change:
int ldrState = LOW;             // ledState used to set the LDR
long previousMillis = 0;        // will store last time LDR was updated
int pos = 0;    // variable to store the servo position

long interval = (4 * 60 * 60 * 1000);           // interval at which to run servo (milliseconds)

void setup() {
  // set the digital pin as output/input:
  pinMode(ldrPin,INPUT); 
  pinMode(lsrPin,OUTPUT);
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}

void loop()
{
  // here is where you'd put code that needs to be running all the time.

  // check to see if it's time to blink the LED; that is, if the 
  // difference between the current time and last time you blinked 
  // the LED is bigger than the interval at which you want to 
  // blink the LED.
  unsigned long currentMillis = millis();
 
  if(currentMillis - previousMillis > interval) {
    // save the last time you blinked the LED 
    previousMillis = currentMillis;   

    // if the LDR is HIGH it is in the dark & program should run:
    if (ldrState == HIGH)
    digitalWrite(lsrPin, HIGH);
{ 
  for(pos = 0; pos < 180; pos += 1)  // goes from 0 degrees to 180 degrees 
  {                                                     // in steps of 1 degree 
    myservo.write(pos);                    // tell servo to go to position in variable 'pos' 
    delay(60);                                   // servo speed 
  } 
  for(pos = 180; pos>=1; pos-=1)     // goes from 180 degrees to 0 degrees 
  {                                
    myservo.write(pos);                  // tell servo to go to position in variable 'pos' 
    delay(60);                                 // servo speed 
  } 
 {                                                     // in steps of 1 degree 
    myservo.write(pos);                    // tell servo to go to position in variable 'pos' 
    delay(60);                                   // servo speed 
  } 
  for(pos = 180; pos>=1; pos-=1)     // goes from 180 degrees to 0 degrees 
  {                                
    myservo.write(pos);                  // tell servo to go to position in variable 'pos' 
    delay(60);                                 // servo speed 
  } 
 }
    digitalWrite(lsrPin, LOW);

Help?

delay(60);

This is supposed to be "without delay", but you've got several.

I did look at the Blink with out delay and I have tried the following sketch:

Well, good for you.

Help?

Sure thing. With what?