Control motor speed?

Hi everyone,

I am very new to Arduino and I am in need of some help. I have a project for school that requires me to use a motor, to raise a platform, that will controlled by Arduino. I was curious if I could vary the speed of my motor? By this I am referring to starting at zero, ramping up to a specific speed at a moderate pace, and then slowing down to zero. I guess the easiest way to explain this is hooking up my motor to a potentiometer and moving it from off, to on, then back off again. Similar to driving miss daisy and not a rocket type of deal if you get what I'm saying. The potentiometer would be my preferred method if I could touch the board, but it has to be autonomous. Any help would be greatly appreciated! :slight_smile:

Thank you all very much,


PWM is another way to achieve what you're looking for - take a look at analogWrite.

PWM is superior to that potentiometer you mentioned.

Ramping up/down from/to 0 will not work like you are expecting at the moment.
It's almost impossible to predict where you will end up, but i can tell you your range will be much less than 0 - 100 (%).

I'd build a test platform and do some tests to find the best values for your application.

Hello JensAI,

Hmm.. controlling the speed of a direct current motor ( DC motor ) is of an average difficult ( at least if you want to make it really cool ).

What you can do to make it simplier is to send a PWM ( pulse width module ) to an analogOutput so it can control the speed rate of a switch. Then the switch could to turn the motor on and off

Best regards!

What you can do to make it simplier is to send a PWM ( pulse width module ) to an analogOutput so it can control the speed rate of a switch. Then the switch could to turn the motor on and off

I don't follow this.
You like to send a pulse width modulated control signal to a switch so that switch switches slower, or what ?

What kind of switch do you have in mind that could be controlled this way ?
Please replace the word "switch" by the correct word of the component you have in mind.
I do agree any motor should not be connected directly to an Arduino pin, and assuming this is known by JensAl is a mistake.

Sorry if i didn’t explain it clearly.
What i mean is that JensAI should only use a PWM to control the switching frequency of a BJT (per example BC549 - general use).
The circuit should be something like the figure attached. ( I’m sorry for HORRIBLE draw. I’m just too tired to turn on my pc and create the schematic :stuck_out_tongue: )

As the PWM goes to 100% the motor speed is at it’s maximum. As the PWM goes down, so does the motor speed, until it completly stops if your PWM is zero.

ps.: BJT’s are semi-conductors that can be used as a switch. Easy to find at eletronic stores (at least here in my city :slight_smile: ).

ps2: Be sure to simulate your circuit before and check the datasheet.

ps3.: I can suggest ORCAD software for simulating (may be a bit complex for a new user but there are plently videos teaching how to use it) and i think it has student version.

You could even try one of the Demo’s of Matlab’s Simulink, if you or your school have the license. It’s easy to do this using Simulink with the Arduino package.

However if you got a few dollars and access to Google’s Play Store, there is another option: Droid Tesla app. It’s pretty easy to use and understand.

What is your motor voltage and amperage? If it is less then 24v dc and 1amp you can use one of the many motor shields
based on the L293 chip. Or make your own H-bridge with transitors or mosfets which will allow you to have any voltage
or amperage. tehn you control these with PWM output which gives reversible direction control, and allows you to slowly
ramp up the speed if you need to.

The circuit should be something like the figure attached.

Not really, because the load's on the wrong side of the NPN transistor 8)

You should consider limit switches too: "bump" switches at the top and bottom of the travel to make sure it switches off and doesn't sit forever trying to grind its way through the end of the system.

The mechanical side of this project might be tricky: how are you going to get the motor to move the platform?- usual approach is some kind of travelling nut on a threaded rod, rod turned by the motor.

Edit: something like this...

Another idea is have you thought of using a stepper motor. Using a stepper with a threaded rod as JimboZA mentioned
is how most CNC and 3D Printers move there components around with great accuracy. I have not used them yet but
there are plenty of examples of code around to give you a idea of how to work it.