Andreee99:
My problem is to control the time that the motor goes forward and backwards.
That is what the delay() calls are doing. You can change the delays to a different constant or change them to variables that you calculate in your sketch.
for testing, you can comment out the print statements. they are there to send text to your screen to tell you what mode you are in.
Serial.println (“Forward”); // this is just to send out text to tell you the state the program is in.
digitalWrite (pinA1, HIGH);
digitalWrite (pinA2, LOW);
//5s backwards
delay (5000); // think this is being used to run the motor ?
digitalWrite(Relay_1, RELAY_ON);// set the Relay ON
delay(400); // wait for a second
digitalWrite(Relay_1, RELAY_OFF);// set the Relay OFF
delay(900); // wait for a second
try changing the delay values for the relays. if they are the devices in control then these would change the time.
without a schematic, it is only guessing, but you said changing the delay in PinA1 had no effect, look here maybe ??
Yes i know that the prints is to write the state on a screen orsomething like that but in thois case in not using any screen so i dont use the prints for nothing.
Ok, in the relays i can control the delay perfectly , i change the time and it works fine.
but in the other case( to control the linear actuator) i cant control the time so i think that the motor is damage .
Other thing i want to do is to make my code run only 3 times? can i do a counter of cycles in the program?