I'm very new to the Arduino world and I have no experience with programming language. I'm using my Arduino UNO R3 to run an automatic door operator. I want the door to open, stay open for a set time, close, and stay closed for a set time, repeat (24 hour cycle). I have developed the following sketches to accomplish this task using an Arduino R3 motor shield. My sketch #1 (quick test) works perfectly but when I upload sketch #2 (my desired timing) the door will open and never will shut. I wonder if the Arduino has an automatic time-out function that I'm not aware of. Can you guys help me trouble-shoot my sketch? Is there a better way to do long term motor shutdown times? Thanks.
// Sketch #1 (my quick test sketch)
//Drive DC motor CW 10 seconds, pause 2 seconds, run motor CCW 10 seconds, pause 2 seconds, repeat.
//L. C. H. 2/23/2013
// Motor definitions
int DIR_A = 12;
int SPEED_A = 3;
int BREAK_A = 9;
void setup()
{
pinMode(SPEED_A, OUTPUT);
pinMode(DIR_A, OUTPUT);
pinMode(BREAK_A, OUTPUT);
// release break
digitalWrite(BREAK_A, LOW);
}
void loop()
{
// run motor CW full speed. (Max is 250)
digitalWrite(DIR_A, HIGH);
analogWrite(SPEED_A, 250);
// run motor for 10 seconds
delay(10000);
// stop motor
analogWrite(SPEED_A, 0);
// pause 2 seconds
delay(2000);
// move motor CCW full speed. (Max is 250)
digitalWrite(DIR_A, LOW);
analogWrite(SPEED_A, 250);
// run motor for 10 seconds
delay(10000);
// stop motor
analogWrite(SPEED_A, 0);
// pause 2 seconds
delay(2000);
}
//Sketch #2 (my long-term-pause sketch w/desired timing)
//Drive DC motor CW for 18 seconds, pause 14 hours, run CCW for 18 seconds, pause 10 hours, repeat.
//L. C. H. 2/24/2013
// Motor A definitions
int DIR_A = 12;
int SPEED_A = 3;
int BREAK_A = 9;
void setup()
{
pinMode(SPEED_A, OUTPUT);
pinMode(DIR_A, OUTPUT);
pinMode(BREAK_A, OUTPUT);
// release break
digitalWrite(BREAK_A, LOW);
}
void loop()
{
// run motor CW full speed. (Max is 250)
digitalWrite(DIR_A, HIGH);
analogWrite(SPEED_A, 250);
// run motor for 18 seconds to open
delay(18000);
// stop motor
analogWrite(SPEED_A, 0);
// pause door open 14 hours (minus 18000 ms runtime)
delay(50398200);
// run motor CCW full speed. (Max is 250)
digitalWrite(DIR_A, LOW);
analogWrite(SPEED_A, 250);
// run motor for 18 seconds to close
delay(18000);
// stop motor
analogWrite(SPEED_A, 0);
// pause door closed 10 hours (minus 18000 ms runtime)
delay(35998200);
}