How to add timer coding in forward reverse motor

int m_forward = 11; int m_reverse = 10; int m_stop = 9; int l_s_forward = 6; int l_s_reverse = 5; int led_forward = 12; int led_reverse = 13;

int m_forward_state = 0; int m_reverse_state = 0; int m_stop_state = 0; int l_s_forward_state = 0; int l_s_reverse_state = 0;

void setup() { pinMode (m_forward,INPUT); pinMode (m_reverse,INPUT); pinMode (m_stop,INPUT); pinMode (l_s_forward,INPUT); pinMode (l_s_reverse,INPUT); pinMode (led_forward,OUTPUT); pinMode (led_reverse,OUTPUT); }

void loop() { m_forward_state = digitalRead (m_forward); m_reverse_state = digitalRead (m_reverse); m_stop_state = digitalRead (m_stop); l_s_forward_state = digitalRead (l_s_forward); l_s_reverse_state = digitalRead (l_s_reverse);

if ( m_forward_state == HIGH && m_reverse_state == LOW ) { digitalWrite ( led_forward, HIGH); digitalWrite ( led_reverse, LOW); //delay (2000); }

if ( m_forward_state == HIGH && m_reverse_state == HIGH) { digitalWrite ( led_forward, LOW); digitalWrite ( led_reverse, LOW); //delay (2000);

}

if ( m_forward_state == LOW && m_reverse_state == HIGH) { digitalWrite ( led_forward, LOW); digitalWrite ( led_reverse, HIGH);

} if ( m_forward_state == LOW && m_reverse_state == LOW && m_stop_state == HIGH) { digitalWrite ( led_forward, LOW); digitalWrite ( led_reverse, LOW); } }

I want the motor moving forward for 5 sec and reverse for 1 minute

Sorry...forward for 30 sec

Please modify your post and use the code button </> so your code looks like this and is easy to copy to a text editor. See How to use the Forum

What does the code that you have posted do?

…R