Controlling the speed of a dc motor?

I was planning on using the PWM im just not exactly sure how to wire it up safely. What about this https://sites.google.com/site/arduinosoapy29/motor-speed-controller schematic? this is more what i want because im not using a potentiometer.