Steps:
[] Generate a sound wave of certain duration (in my case 10 seconds) with high frequency (say 20000 Hz) using my Scilab toolbox for tone generation.
[] Cut a wire from an old pc headphone including the TRS connector
[] Connect one end of the dc motor with a diode and the other end of the diode with any wire out from the sound card.
[] Connect the second wire with the motor
[] Run the sound file with any media player and control the speed via volume control slider
Note: wave rectification is done by hardware (diode) and is not going to work when done by software
Note: when motor is connected without diode it is not going to rotate and it will behave as a speaker (you can hear songs from the motor!)