How this came about:
I recently was working on an instructable about charlieplexing with an arduino. And I was wondering if the same principle would work with motors to some extent. So I came up with the idea that if you used a motor instead of an led you could have 2-way control of it & if you used 2 PWM (Pulse Width Modulation) ports you could have 2-way variable speed control for a motor with no external hardware!! So I decided to post my findings. Have fun! If you have any questions Please ask them.
Note: This is not the safest way to control a motor. Each I/O pin can only handle 40 mA of current. I would recommend using a H-Bridge as pointed out by: Bongmaster & Frollard.
I am not responsible for any thing bad that happens to you or to your arduino!
Remove these ads by
Signing UpStep 1The stuff you need:
- Arduino
- Small DC motor
- Wire for motor
Tools:
- Computer with Arduino IDE installed
- A-B USB cord
| « Previous Step | Download PDFView All Steps | Next Step » |







































A motor is not an entirely resistive object. It has also some inductance. What does that mean? It means that when you reverse the voltage on the pins, the current doesn't change its direction immediately. So, for a short moment, the motor acts like a current source.
And that could effectively blow up your microprocessor.
but, for big motors, use analog io or gnd+digital with an external driver is better (obviously)''
but, yet, is a great idea
http://www.kpsec.freeuk.com/trancirc.htm
(scroll down to protection diode)
u can make a simple h bridge from transistors like i did here
http://bongmasters-things-and-stuff.blogspot.com/2009/05/robot-h-bridge-pair-motor-driver.html
using the schematic on this page
http://www.beam-online.com/Robots/Circuits/circuits.html
there was a 4 transistor version somewhere too. cant remember where tho XD
hence why i built the h-bridge pair i linked ;) better safe XD
Totally agreed in using an h-bridge, driven by these pins.
using pwm just means you're turning it on and off MANY times...more risk of burning out that expensive pin....my 2 cents.