Ok so I take your advice and repair my program.
Now when I press open on rf remote relayA1 start to open and continiue until limitA1 is open.
And then when limitA1 is close then relayA2 starts to open.
here is new code:
// constants won't change. They're used here to
// set pin numbers:
#define limitA1Pin 2 // the number of the close door 1 safety switch
#define limitA2Pin 3 // the number of the open door 1 safety switch
#define limitB1Pin 4 // the number of the close door 2 safety switch
#define limitB2Pin 5 // the number of the open door 2 safety switch
#define rfOpenPin 6 // the number of the RF Supra input OPEN pin
#define rfClosePin 7 // the number of the RF Supra input CLOSE pin
#define relayA1Pin 8 // the number of output for door1
#define relayA2Pin 9 // the number of output for door2
#define relayB1Pin 10 // the number of output for door1
#define relayB2Pin 11 // the number of output for door2
#define ledPin 13
// variables will change:
int limitA1 = 0;
int limitA2 = 0;
int limitB1 = 0;
int limitB2 = 0;
int rfOpen = 0;
int rfClose = 0;
int relayA1 = 0;
int relayA2 = 0;
int relayB1 = 0;
int relayB2 = 0;
void setup()
{
pinMode(limitA1Pin, INPUT); // initialize the pin as an input:
pinMode(limitA2Pin, INPUT); // initialize the pin as an input:
pinMode(limitB1Pin, INPUT); // initialize the pin as an input:
pinMode(limitB2Pin, INPUT); // initialize the pin as an input:
pinMode(rfOpenPin, INPUT); // initialize the pin as an input:
pinMode(rfClosePin, INPUT); // initialize the pin as an input:
pinMode(relayA1Pin, OUTPUT); // initialize the pin as an output:
pinMode(relayA2Pin, OUTPUT); // initialize the pin as an output:
pinMode(relayB1Pin, OUTPUT); // initialize the pin as an output:
pinMode(relayB2Pin, OUTPUT); // initialize the pin as an output:
pinMode(ledPin, OUTPUT);
}
void doorMoveA1()
{
digitalWrite(relayA1Pin, LOW);
while(digitalRead(limitA1Pin) == LOW)
{
// do nothing
}
digitalWrite(relayA1Pin, HIGH);
}
void doorMoveA2()
{
digitalWrite(relayA2Pin, LOW);
while(digitalRead(limitA2Pin) == LOW)
{
// do nothing
}
digitalWrite(relayA2Pin, HIGH);
}
void doorMoveB1()
{
digitalWrite(relayB1Pin, LOW);
while(digitalRead(limitB1Pin) == LOW)
{
// do nothing
}
digitalWrite(relayB1Pin, HIGH);
}
void doorMoveB2()
{
digitalWrite(relayB2Pin, LOW);
while(digitalRead(limitB2Pin) == LOW)
{
// do nothing
}
digitalWrite(relayB2Pin, HIGH);
}
void doorOpen()
{
doorMoveA1();
delay(3000);
doorMoveA2();
}
void doorClose()
{
}
void loop()
{
digitalWrite(relayA1Pin, HIGH);
digitalWrite(relayA2Pin, HIGH);
digitalWrite(relayB1Pin, HIGH);
digitalWrite(relayB2Pin, HIGH);
rfOpen = digitalRead(rfOpenPin);
rfClose = digitalRead(rfClosePin);
if (rfClose == HIGH) {
digitalWrite(ledPin, HIGH);
doorOpen();
}
else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}