Simple 2-way motor control for the arduino
Simple 2-way motor control for the arduino
When I say simple, I don't mean use a speed control. But control the motor directly without any external circuitry. Here's how:

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!

Step 1: The stuff you need:

Simple 2-way motor control for the arduino
Parts:
- Arduino
- Small DC motor
- Wire for motor

Tools:
- Computer with Arduino IDE installed
- A-B USB cord

Step 2: Connecting the motor

Simple 2-way motor control for the arduino
Simple 2-way motor control for the arduino
Simple 2-way motor control for the arduino
Simple 2-way motor control for the arduino
Connect your DC motor to your arduino.

- Connect one wire from the motor to pin 5 on you arduino
- Connect the other wire from your motor to pin 6 on your arduino

The hardware setup for this is pretty simple.

Step 3: Coding the Arduino

Simple 2-way motor control for the arduino
Here's some basic steps to program your arduino.

1) Download the source code from below
2) Open the file in the Arduino IDE
3) Press the "Upload to I/O Board" button
4) Once the program is uploaded it will start running


I tried to add a good amount of comments to the code, but if you have any questions, please ask them.
Simple 2-way motor control for the arduino
_2Way_Motor_Control.pde1 KB

Step 4: How this works & more Ideas

Simple 2-way motor control for the arduino
Simple 2-way motor control for the arduino
How This Works:
When you make one pin HIGH & another LOW, the pin that is HIGH has a positive voltage & the pin that is LOW works like a ground(-).

Note: The rotation direction maybe different than below.

Pin 5: Pin 6: Rotates: HIGH LOW CCW LOW HIGH CW PWM: 127 LOW CCW 1/2 Speed
CCW = Counter Clockwise
CW = Clockwise

Ideas:
Add a second motor. Sorry I don't have any code for this, But there is a schematic posted below.
 
 

Tag cloud

make build easy simple arduino making homemade solar laser printed portable cheap mini building custom cardboard wooden create super lego turn paracord chocolate your paper light intel