Thanks everyone.
I have been trying several things with my sketches and I have developed a very simple program that I think will meet my needs. Also, maybe I failed to let you guys know that I already have an Arduion UNO R3 and an Arduino motor shield R3. I have been having a real struggle trying to remember ANY of the C++ programming language that I used to know so well. Trying to remember things is like trying to walk on two rubber legs after my stroke. Sometimes I feel totally useless.
My needs for the motor control are as follows -
- Run motor CW for 18 seconds
- Stop motor (without break)
- Pause 14 hours
- Run motor CCW for 18 seconds
- Stop motor (without break)
- Pause 10 hours
That's it. I know it may seem simple to you but I'm struggling. As you will see in my sketch below, I'm using nano-seconds for my timing commands. I'm pretty sure there is a better way to program lengthy MOTOR OFF periods but I simply cannot remember. Any advise would be appreciated.
Anyway here is my sketch: (please comment on ways to simplify or to streamline - thanks)
// Drive a simple DC motor forward and backward at full
// speed with timed pause between each run. 2/24/2013
//
// Motor connected to Motor output A on Arduino Motor Shield R3
// Motor A definitions
int DIR_A = 12;
int SPEED_A = 3;
int BREAK_A = 9;
// Motor B definitions
int DIR_B = 13;
int SPEED_B = 11;
int BREAK_B = 8;
void setup()
{
pinMode(SPEED_A, OUTPUT);
pinMode(DIR_A, OUTPUT);
pinMode(BREAK_A, OUTPUT);
// release break
digitalWrite(BREAK_A, LOW);
}
void loop()
{
// run motor backward full speed. (Max is 250)
digitalWrite(DIR_A, HIGH);
analogWrite(SPEED_A, 250);
// run motor for 18 seconds to open door
delay(18000);
// stop motor
analogWrite(SPEED_A, 0);
// pause door open 14 hours (minus run time)
delay(50398200);
// run motor forward full speed. (Max is 250)
digitalWrite(DIR_A, LOW);
analogWrite(SPEED_A, 250);
// run motor for 18 seconds to close door
delay(18000);
// stop motor
analogWrite(SPEED_A, 0);
// pause door closed 10 hours (minus run time)
delay(35998200);
}