atmega168(v) + L293D + DC motor


I'm new to this forum and I'm also new to working on projects with micro-controllers and I hope I can get some help here. Thank you all in advance.

The project I am working on would require the start/stop & direction of motion of a motor to be controlled based upon some calculations. As for motor speed, the maximum I need should be 1rev/day and it would be great if I could also control this with the controller.

After some research, I am thinking of interfacing the Atmega168 micro-controller with the DC motor using the L293D H-Bridge. But before going on to buy the parts, I want to make sure that it would work out esp. that the Atmega168 micro-controller is sufficient for my needs. So, my main question is "What specifications are most important in choosing a micro-controller?"

Here are a few things I have considered: - Input / Output pins: I beleive I'll need between 0-3 input pins and 3 ouput pins (the L293D chip requires only 3 inputs to control one motor). It seems the Atmega168 has 23 pins which should be way more than enough. - Speed: Low speed should be sufficient. - Memory: I have found part of the code for the calculation I need in Javascript (13.5KB) and in C# (about 5KB) but I would have to add some code to this and this is what worries me most - whether the 16K flash memory of the Atmega168 would be sufficient for all the code I need to put on it especially if I were to migrate the code I found to C or assembly language and add what I need to add. [Does the controller accept code in any language other than C or assembly?]

Lastly, is there anything I should watch out for in using the L293D to interface with the DC motor?

Thanks a lot for you help, Sadiq.

Sorry, one last thing: I found the Atmega168V is slower than the Atmega168. Since low speed should be enough for me, I guess I can get the Atmega168V instead of the Atmega168V - is this a correct assumption?

I'm sorry but two other things I needed to ask:

Would you recommend this board: Arduino USB Board? Also, what websites are cheapest to get these parts? (I'm in the US).

Thanks again.

Just a couple of quick thoughts for you.

It's physically impossible to control an ordinary DC motor so it only turns 1 rev/day. You're going to need to gear it down by hundreds (if not thousands) to 1, and will probably want to use a stepper motor for precise control.

It's really hard to estimate how much memory you'll need based solely on source code size. Languages like Javascript and C# have huge libraries of subroutines supporting them, and a single line of source code might do something like fire up a web browser, or even a web server, that would far exceed the capacity of a microcontroller. Depending on what's in that code, it could be either "no problem" or "completely impossible". It might make sense for you to run that code on a PC, and use the microtroller as a "peripheral" on that PC.

The board you referenced is a good place to start for learning about micros The Arduino Way. As it happens, NKC Electronics ( is currently running a promotional special on a limited quantity of very similar boards for several dollars less. Since you're probably not going to need the ability to plug in shields (Arduino I/O boards), you might also consider the boards from they're much cheaper (especially if you assemble them yourself), and more convenient to plug into your own custom electronics than a standard Arduino.

For ease of getting up to speed, consider prototyping with a standard Arduino and the motor control shield from you'll start from a proven design, and can tweak it for cost reduction later.

One final thing to watch out for: make sure the L293 can handle the current required by your chosen motor. Many have been surprised to find out that the motor needs a lot more current than they thought it would.


If you only ned to control the motor then you might get away with a simpler micro processor than Arduino, but considering that the software for programming Arduino is free, and the wast amount of code and experience available i wold go for Arduino. It's such a cool micro :-)

And as Ran said it's very difficult to get a DC motor to run as slow as you need. With an ordinary motor without gearing it is impossible, the mortro will just come to a halt.

A stepper motor is probably a better idea.

Is the motor going to lift / turn something heavy ?

Thanks a lot for your replies, Ran & MikMo.

About the weight of what the motor would be moving, I approximate it would be about 10lbs max.

Thanks again, Sadiq.