DC Motor Speed Variation

Hi,
This is my first post on the forum. I am currently building a self balancing robot. I am new to robotics and have brought a USB arduino clone. I am still to go to the sensors stage but I am working out the basics. Using the arduino I have managed to run 2 dc Motors using an L293D HBridge IC and have managed to reverse the direction of rotation using a switch. Can somebody guide me on how to proceed to control the speed of the DC motors using my arduino (the motors are 12V and around 100rpm). My initial guess is that this will be done by PWM but I am not sure how to proceed with the hardware circuitry and the programming of the code. I want to control the speed of the motor and not just forward, reverse, and stop. How can it be done using a breadboard and a setup similar to the one used in making them run with an L293D? http://itp.nyu.edu/physcomp/Labs/DCMotorControl

I tried learning from the fading led sketch but was unsuccessful since the led simply lit up and lit off at a particular potentiometer value. Any one know why this is happening?

I tried learning from the fading led sketch but was unsuccessful since the led simply lit up and lit off at a particular potentiometer value

Maybe your pot had a dirty track.
Debug prints are useful in situations like these.

thanks i will try that !!!! any idea about how i can control a dc motor speed with a pot?

tejasinamdar:
thanks i will try that !!!! any idea about how i can control a dc motor speed with a pot?

Feed the PWM output of the Arduino to the enable pin for the motor on the L293:

http://www.kmitl.ac.th/~kswichit/c52robot/c52robot.htm