So I am buzzy with a project involving a AC gate motor and solar panels.
Basically there is no AC power at the cate and it is to far to pull a cable for it so the solution is a solar panel charging a battery and then the battery supplying power to an power inverter , the problem I am having is that the inverter is always on so drawing power even if no load is connected.
So what I am planning on doing is using the Arduino Duemilanove and two 5 volt relays.
What I want to happen is, I want to connect the gate motor Receiver to the Arduino to supply an analog input to the Arduino when I press the button to open the gate. What I want to happen is after the signal is received the Arduino switch on a relay for say 30 seconds , this will turn on the inverter, also say 2 seconds after the signal is received pulse a another relay for 1 second , to trigger the gate to open .
So basically after pressing the button to open the cate the Arduino will switch on the inverter for 30 seconds and also trigger the gate 2 seconds after that, the gate has a auto close feature so I will be relying on that to close the gate. Then like I said after 30 seconds the first relay must also de energise thus turning of the inverter and saving battery power.
Can someone please help me with the programming, I am new to this programming platform.
The receiver is basically a relay that is energized when you press the remote button so you can easily switch 5 v with it to give a signal to the arduino.
i am a Millwright( electric and mechanical qualifid ) i have grate experience with plc programming in lader and electrical and electronics , only thing is i do not know how to make the arduino do this specif task lol
On my gate I went all DC (With solar charging) but I was making the entire controller using a linear actuator....
Anyway this may help you get started,... If you ground pin 2 it will turn on relay 1 on a a 2 channel relay board, wait 2 seconds turn on relay 2, wait 2 seconds turn off relay 2, wait 30 seconds turn off relay 1
(This code is not test and was written very quick test it)
const int MoveGatePin = 2; //Set Position
const int Relay1Pin = 3; //Relay Inverter
const int Relay2Pin = 4; //Relay GateMove
boolean movegate = false;
boolean relay2 = false;
unsigned long tmrinverteron = 0;
unsigned long tmrwaittomove = 0;
unsigned long tmrholdrelayon = 0;
void setup() {
// Starting the serial interface
 Serial.begin(19200);
Â
// SET INPUT PIN
 pinMode(MoveGatePin, INPUT);
 digitalWrite(MoveGatePin, HIGH);
// SET PINS FOR RELAY BOARDÂ HIGH FOR OFF LOW FOR ON
 pinMode(Relay1Pin, OUTPUT);
 digitalWrite(Relay1Pin, HIGH);
 pinMode(Relay2Pin, OUTPUT);
 digitalWrite(Relay2Pin, HIGH);
}
void loop() {
  //wait for pin 2 grounding
  while ( ( !digitalRead(MoveGatePin) ) and ( !movegate ) ) {
   movegate = true;
   tmrinverteron = millis();
   tmrwaittomove = millis();
  }
  if ( movegate ) {
    digitalWrite(Relay1Pin, LOW); // TURN ON INVERTER
   Â
    // WAIT 2 SECONDS ACTTIVATE 2nd RELAY
    if ( ( millis() - tmrwaittomove > 2000 ) and ( !relay2 ) ) {Â
     // TURN ON 2nd Relay
     digitalWrite(Relay2Pin, LOW);
     // SET COUNTER FOR TURN OFF
     tmrholdrelayon = millis();Â
     relay2 = true;
    }
   Â
    // WAIT 2 SECONDS ACTTIVATE 2nd RELAY
    if ( ( millis() - tmrholdrelayon > 2000 ) and ( relay2 ) ) {Â
     // TURN OFF 2nd Relay
     digitalWrite(Relay2Pin, HIGH);
    }
   Â
    // IF INVERTER ON 30 SEC TURN OFF
    if ( millis() - tmrinverteron > 30000 ) {
     // TURN OFF INVERTER
     digitalWrite(Relay1Pin, HIGH);
     movegate = false;
     relay2 = false;
    }
  }
 delay(5);
}
i was wondering is it possible to write the code is such a way that after the relay has activated for 30 seconds and the second relay activates for 2 seconds , is it possible to then write it that when the pin 2 is ground again that the second relay activate again for 2 second but the main relay still deactivate after 30 seconds ?