Need help with programing please?

Hello,
( I have searched for a few days and tried to write a program but failed in both aspects.) with that said...
I have a project that I need some help with. I have an arduino micro and I am completely new to programing and have no idea what i am doing
on the programing side of this project. What I would like to do is run a 12vDC motor bidirectionally for a set amount of time. and have it be triggered by a voltage signal (or ground???) to the arduino micro. So when voltage is applied to (input pin) the motor spins cw for (time) then stops even though power (or ground???) is still applied to (input pin). When power is removed from (input pin) motor spins ccw for (time) then stops until power is applied again. If i can be steered in the right direction or if someone is nice enough to write the program i would be very thankful.

I attached a picture to show my setup/ or what i think is correct. im not sure completely as i am somewhat new to semiconductors

Have you tried a regular H-Bridge? Also you cannot have both USB and battery plugged into the arduino together.

HazardsMind:
Have you tried a regular H-Bridge? Also you cannot have both USB and battery plugged into the arduino together.

Sorry for my ignorance as i am totally new to programming and somewhat new to semiconductors. No i haven't, when you say regular h-bridge do you mean a semiconductor style? and i only would have the usb power to actually power the board the other power wire is the switched power to the pin, unless i can only have a switched ground?

Yes, an actual chip. Or if you have a few transistors lying around, you can make your own H bridge. Look up H-Bridge IC

Wow - that diagram is confusing. Do you really have ground and 12 volts going to each motor terminal as it appears ? I can't tell from the diagram which contacts on the relays are switching what. Can you post a more conventional circuit diagram ?

As has been suggested an H bridge (Google for it) would be the normal way to control motors using an Arduino. There is nothing wrong with using relays but they are on/off devices. An H bridge (motor shield) would allow speed control of the motors which, is nothing else, allows you to soft start them which can be kinder than starting them at full power each time.

UKHeliBob:
Wow - that diagram is confusing. Do you really have ground and 12 volts going to each motor terminal as it appears ? I can't tell from the diagram which contacts on the relays are switching what. Can you post a more conventional circuit diagram ?

As has been suggested an H bridge (Google for it) would be the normal way to control motors using an Arduino. There is nothing wrong with using relays but they are on/off devices. An H bridge (motor shield) would allow speed control of the motors which, is nothing else, allows you to soft start them which can be kinder than starting them at full power each time.

I dont even know how to write a program to do any of this, let alone soft start a motor, lol =(

Start with the examples and maybe even a forum search, there is plenty of codes in here to help you get started.

You have a range of options available to you. A hardware based solution would need a couple of relays controlled by a couple of 555 timers, no electronics.

The easiest Arduino-based solution would use a UNO or similar with an H-bridge motor drive shield and a sketch that reads the input and turns the motor on forwards and backwards as required. Is your intended motor within the voltage and current capabilities of any of the commonly available motor shields? For example the L298N based shields supports voltages well in excess of 12V and will handle up to about 4A.

slovw3:
I dont even know how to write a program to do any of this, let alone soft start a motor, lol =(

lol indeed.

A clearer circuit diagram would be a start.