speed control in rpm

I want to control speed of motor by giving a rpm value. But all i found is by pwm. how can i control motor with rpm instead of pwm with arduino?? any code or relation

But all i found is by pwm. how can i control motor with rpm instead of pwm with arduino?

You write some formula that converts an RPM value into a PWM value.

As the relationship between RPM and PWM is different for each type / size / voltage of motor there is no universal way to do this, you have to tailor it to the motor.

I want to control speed of motor by giving a rpm value

Assuming a regular DC motor with the proper driver circuit & voltage....

A PWM value of 255 will give you maximum speed. A PWM value of zero will turn the motor off. In-between values will give you in-between speeds. (But, a value of 127 won't necessarily be half-speed.)

If you want to control the speed with a pot and you don't need an exact speed, you can simply map() the pot readings to PWM values.

Or, if you just need a 3-speed fan control (where the exact RPM isn't important) you can determine the PWM values experimentally.

If you need precise speed control you need a sensor to read the speed of the motor. Then, you your program with a "feedback loop" to adjust the PWM up or down as needed to hit and maintain that speed. Once that's set-up, you tell the software what RPM you want and the software figures-out the PWM value. That's how the cruse control works in your car... It doesn't give the car a pre-set amount of fuel, it gives it whatever fuel is needed to maintain the speed.

Usually, you have to build something (with optics or with a hall effect sensor) to measure the speed. But there are [u]computer fans[/u] with built-in speed sensors.