why do you have 2 topics about this. Code is code. If you know how to write for a 16F, you basically know about a 18F they just have extra stuff. I posted to you to search the forum. There is code on here for what you want. No one is going to write the whole this out.
Look on the forum you will find it, it may be for a 18F but should not be hard to convert to 16F