Linear Actuator run time

Hi,

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

I hope to use a relay and mainly understand the code to set the relay between high and low but most examples shown are using a delay where as I want the actuator to run for a set time.

I think you are misreading the code you supplied.

 digitalWrite(RELAY1,LOW);           // Turns ON Relays 1
 delay(2000);                        // Wait 2 seconds
 digitalWrite(RELAY1,HIGH);          // Turns Relay Off

For example this section.

  • Turns the relay ON
  • Stops the code for 2000mS, the relay STAYS ON.
  • After 2000mS lets the code run.
  • Turns the relay OFF.

So the relay stays ON for 2000mS.

The problem with using delay() is that it STOPS the code, so NOTHING gets done.
Using millis as UKheliBob has linked for you, you can still get the same output, but the code keeps running, so it can do other processes.

Have you setup a controller, relay and tried some code?

Tom... :slight_smile: