I want to control 4 steppers with Arduino UNO and I'm all short of PWMs.In every tutorial over the web they have used PWM pin , in that case I can at-most use only two steppers with Arduino.So why it has to be PWM only that is to be used or is there a way I can extend PWMs on my board either with software or hardware ? for example : We use softwareserial library to get Rx, Tx pins .

Here are some of the tutorials :



  • 1
    \$\begingroup\$ I don't have time for a real answer now, so I'll just write this: You can do PWM in software with no problems at all. The simplest way to do that would be to make a loop which will do counting. At the beginning, set a pin to high and then during each loop iteration, check the counter value. Once it reaches the percentage of time you need the pin to be high, set the pin to low. Another, less processor-intensive, way to do that would be to set up timer interrupts and then set the pin state in the interrupt service routine. \$\endgroup\$
    – AndrejaKo
    Dec 27, 2013 at 7:40
  • \$\begingroup\$ This is just an fyi. Keep an eye on the Arduino proposal on Area 51. \$\endgroup\$ Dec 27, 2013 at 7:50
  • \$\begingroup\$ Can anyone explain how exactly PWM drives the motor? I mean why 3PWMs pins (for 4 wire steppers) are needed? \$\endgroup\$
    – thebugger
    Dec 27, 2013 at 8:14

1 Answer 1


There is a function in Arduino analogWrite() which can generate PWM waves. Any analog pin can be converted to PWM output pin. But this is software controlled. So your code will be spending its major time in making the PWM signals rather than doing other useful works.

There is also a PWM sheild from Sparkfun. Try making this one yourself(circuit is available) or buy one board - https://www.sparkfun.com/products/10615

Don't use a PWM for controlling stepper motors. This is a complex method. Also if you use PWM to control stepper motors, you also require additionally a H-bridge/Driver IC(Arduino cannot drive motors directly since Arduino can only provide very less current which is not enough for motors to work).

Use stepper motor drivers for controlling stepper motors. You don't need PWM outputs to drive these stepper drivers. Only GPIO pins are required. Also these stepper motor drivers also include the H-Bridge/Driver IC. Check this link which explains how stepper motors are controlled using stepper drivers and their connection diagram.


  • \$\begingroup\$ Let me tell you what I'm trying to make , this is my actual question electronics.stackexchange.com/questions/94723/… I'm actually trying to implement and run the steppers via making stepper drivers itself.I was using l293d earlier but that utilizes PWM pin. I think I cannot use the already built motor drivers as they cost much \$\endgroup\$
    – thebugger
    Dec 27, 2013 at 9:35
  • \$\begingroup\$ If stepper motor drivers are costlier, then H-Bridges are the next option. Using software to generate PWM is not a good option especially when you have to do other works with your Arduino. PWM should be generated using the hardware modules. Arduino Mega has few more when compared to Uno. You will have to use a Arduino Mega to drive stepper motor along with L293D. Check this link (Arduino Mega and stepper drivers)reprap.org/wiki/Arduino_Mega_Pololu_Shield \$\endgroup\$
    – robomon
    Dec 27, 2013 at 9:50
  • \$\begingroup\$ Thank you for answering ,Did you read my question ? My whole motive is to make stepper drivers so that I can run my motors. I am hardly doing any other things with the Arduino. So can I use a single uno itself to make the drivers with L293D? What software changes will I have to do ? Is that steppper library doesn't work at all without PWMs ? I want speed , step and direction control , would then I be able to achieve that ?. Thank you @robomon , you are very helpful. Happy Holidays and Merry Christmas :) \$\endgroup\$
    – thebugger
    Dec 27, 2013 at 10:00
  • \$\begingroup\$ You are welcome! Please vote for my answer if you found useful. You can drive 1 motor with Arduino but driving more requires PWM modules which will cost money. Check these links learn.adafruit.com/… , arduino.cc/en/Tutorial/StepperUnipolar \$\endgroup\$
    – robomon
    Dec 27, 2013 at 10:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.