Motor Code Help

Hey everyone, I just bought an arduino and a 12V motor. Im completely new to this and I need all the help I can get for a DIY home project.

Firstly, I know I can't use a 12V motor with an arduino because it will burn out but Ive been looking up different ways to do this and I was leaning towards the cable that plugs into the outlet to power my arduino. What do you recommend?

Secondly, I need a nice and simple code to get my motor to rotate for 5 seconds and then stop. Can someone please give me a code to do this? I already have a code to change the speed of the motor. Is there a way I can combine these codes to have my motor move slowly for 5 seconds?

Thanks guys! Cant wait to get this started!

Hello and welcome to the forum.
First, please read the “How To” sticky at top of page.

Well, we are going to need a tad more info, like:
What type of motor? Brushed DC, Brushless DC, Stepper, Servo, AC ?
What size? Full load current, RPM, Steps per rotation? Etc, etc.
Can you post a link to the seller and data sheet?
The more info the quicker the answers.
And please post your existing code using the ( </> ) Icon at top left of reply box.

Suggest you look at some of the simple examples like BlinkWithoutDelay for how
to sequence actions.

The demo Several Things at a Time is an extended example of BWoD.

...R

ManofSteel47:
Firstly, I know I can't use a 12V motor with an arduino because it will burn out but Ive been looking up different ways to do this and I was leaning towards the cable that plugs into the outlet to power my arduino. What do you recommend?

The Arduino cannot drive any motor by itself, it does not have high current outputs, they are limited
to 40mA absolute maximum, ie about 25mA in practice.

You always need a motor driver of some sort, but you've not said what your motor is, nor made
it clear if you want unidirectional, bidirection drive and/or speed control.