ARDUINO PWM

djsfantasi

Joined Apr 11, 2010
9,237
Why with the exception of pin 3? While I can't recall using pin 3 for PWM why can't it be used? I'm curious on that note.

Ron
You CAN use pin 3, but it has another commonly used assignment. Unless you’re absolutely confident in what you’re doing, it’s best to avoid pin 3.

Let’s say you’re debugging a sketch. Most Arduino models don’t have built-in debugging. So you add debug code to serial print intermediate values and statito the IDE console. You’ve created a difficult to find coding error. Because the IDE console is written to using pin 3. Or if your sketch uses the USB interface, you’ve crashed your sketch. Because the Arduino uses pin 3 for USB communication.

Hence, I routinely recommend that unless absolutely necessary and you know what you’re doing, that you avoid using pin 3 for PWM.

Update: fixed typos.
 

Thread Starter

beatsal

Joined Jan 21, 2018
425
I had a similar requirement where, at short notice, I had to drive a small 12V motor using an arduino. I used an IRFZ44 MOSFET, with its gate switched by a transistor. I had a small 5V DPDT relay with 2 Amp contacts laying around so I used it, driven by a transistor, to reverse the motor. If you use a relay, make sure the motor has stopped before you switch the relay or the back EMF will weld or burn off the contacts.
View attachment 252966
Wonder how to interface this with the 2 DAFURUI motor drivers for the 2 motors?
 

Thread Starter

beatsal

Joined Jan 21, 2018
425
DaFuRui 8Pack DC 5V-36V 15A(Max 30A) 400W MOS Transistor Driving Controller Dual High-Power 0-20KHz FET PWM Trigger Switch Driver Module Adjustable Switch Control Board Motor Speed Lamp Brightness
 

Thread Starter

beatsal

Joined Jan 21, 2018
425
Still looking for something like the L298 which drives 2 motors F, R, but with a rating of 10 A FOR EACH MOTOR. Using a separate relay as suggested may be an option but preferable is to find a motor driver controlled by the PWM output of the UNO, which can drive 2 motors X 10 A.
 

Thread Starter

beatsal

Joined Jan 21, 2018
425
I had a similar requirement where, at short notice, I had to drive a small 12V motor using an arduino. I used an IRFZ44 MOSFET, with its gate switched by a transistor. I had a small 5V DPDT relay with 2 Amp contacts laying around so I used it, driven by a transistor, to reverse the motor. If you use a relay, make sure the motor has stopped before you switch the relay or the back EMF will weld or burn off the contacts.
View attachment 252966
Only problem here is that my 2 motors are each 1.6A noload and 25 A STALL. May need a bigger relay/components possibly?
 

KeithWalker

Joined Jul 10, 2017
3,607
You will need a relay with a higher current rating but the stall current will not be a problem if you always use a soft start. To do that, the motor is started at the lowest speed possible and then it is gradually ramped up.
 

KeithWalker

Joined Jul 10, 2017
3,607
You will need a DPDT relay for each motor. The contact DC current rating should be a bit higher than the current that the motors will draw under maximum load for your application.
 
Top