Head Movement

I need to make it so that when I am touching the ground and moving my players head camera will start to bob using a script. how would I do this and make it look realistic?

http://wiki.unity3d.com/index.php/Headbobber

And put something like below in you script to call it when grounded.

if(controller.isGrounded){
    headBob();
}